<commit_before>/************************************************************************
 *
 * $Id$
 *
 * C-Wrapper for GEOS library
 *
 * Copyright (C) 2005 Refractions Research Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation. 
 * See the COPYING file for more information.
 *
 * Author: <NAME> <<EMAIL>>
 *
 ***********************************************************************
 *
 * GENERAL NOTES:
 *
 *	- Remember to call initGEOS() before any use of this library's
 *	  functions, and call finishGEOS() when done.
 *
 *	- Remember to GEOSGeom_destroy() all returned GEOSGeom, and
 *	  to free all returned char *.
 *	  This might change before release.
 *
 ***********************************************************************/

 
/************************************************************************
 *
 * (Abstract) type definitions
 *
 ***********************************************************************/

typedef void (*GEOSMessageHandler)(const char *fmt, ...);
typedef struct GEOSGeom *GEOSGeom;

/* Supported geometry types */
enum GEOSGeomTypeId {
	GEOS_POINT,
	GEOS_LINESTRING,
	GEOS_LINEARRING,
	GEOS_POLYGON,
	GEOS_MULTIPOINT,
	GEOS_MULTILINESTRING,
	GEOS_MULTIPOLYGON,
	GEOS_GEOMETRYCOLLECTION
};


/************************************************************************
 *
 * Initializzation, cleanup, version
 *
 ***********************************************************************/

extern void initGEOS(GEOSMessageHandler notice_function,
	GEOSMessageHandler error_function);
extern void finishGEOS(void);
extern const char *GEOSversion();


/************************************************************************
 *
 * Input and Output functions, return NULL on exception.
 *
 ***********************************************************************/

extern GEOSGeom GEOSGeomFromWKT(const char *wkt);
extern char *GEOSGeomToWKT(const GEOSGeom g);

extern GEOSGeom GEOSGeomFromWKB_buf(const char *wkb, size_t size);
extern char *GEOSGeomToWKB_buf(const GEOSGeom g, size_t *size);


/************************************************************************
 *
 * Memory management
 *
 ***********************************************************************/

extern void GEOSGeom_destroy(GEOSGeom g);


/************************************************************************
 *
 * Topology operations - return NULL on exception.
 *
 ***********************************************************************/

extern GEOSGeom GEOSIntersection(GEOSGeom g1, GEOSGeom g2);
extern GEOSGeom GEOSBuffer(GEOSGeom g1,double width, int quadsegs);
extern GEOSGeom GEOSConvexHull(GEOSGeom g1);
extern GEOSGeom GEOSDifference(GEOSGeom g1,GEOSGeom g2);
extern GEOSGeom GEOSSymDifference(GEOSGeom g1,GEOSGeom g2);
extern GEOSGeom GEOSBoundary(GEOSGeom g1);
extern GEOSGeom GEOSUnion(GEOSGeom g1,GEOSGeom g2);
extern GEOSGeom GEOSPointOnSurface(GEOSGeom g1);
extern GEOSGeom GEOSGetCentroid(GEOSGeom g);
extern char *GEOSRelate(const GEOSGeom g1, const GEOSGeom g2);
extern GEOSGeom GEOSPolygonize(GEOSGeom geoms[], unsigned int ngeoms);

/************************************************************************
 *
 *  Binary predicates - return 2 on exception, 1 on true, 0 on false
 *
 ***********************************************************************/

extern char GEOSRelatePattern(const GEOSGeom g1, const GEOSGeom g2,
	const char *pat);
extern char GEOSDisjoint(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSTouches(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSIntersects(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSCrosses(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSWithin(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSContains(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSOverlaps(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSEquals(const GEOSGeom g1, const GEOSGeom g2);


/************************************************************************
 *
 *  Unary predicate - return 2 on exception, 1 on true, 0 on false
 *
 ***********************************************************************/

extern char GEOSisEmpty(const GEOSGeom g1);
extern char GEOSisValid(const GEOSGeom g1);
extern char GEOSisSimple(const GEOSGeom g1);
extern char GEOSisRing(const GEOSGeom g1);
extern char GEOSHasZ(const GEOSGeom g1);


/************************************************************************
 *
 *  Geometry info
 *
 ***********************************************************************/

extern int       GEOSGeomTypeId(const GEOSGeom g1);
extern int       GEOSGetNumCoordinate(const GEOSGeom g1);
extern GEOSGeom  GEOSGetGeometryN(GEOSGeom g1, int n);
extern GEOSGeom  GEOSGetExteriorRing(GEOSGeom g1);
extern GEOSGeom  GEOSGetInteriorRingN(GEOSGeom g1,int n);
extern int       GEOSGetNumInteriorRings(const GEOSGeom g1);
extern int       GEOSGetSRID(const GEOSGeom g1);
extern int       GEOSGetNumGeometries(const GEOSGeom g1);
extern void      GEOSSetSRID(GEOSGeom g, int SRID);
<commit_msg>Removed functions returning not-new GEOSGeom objects to avoid ambiguity whereas when to destroy returns. Added not about memory management.<commit_after>/************************************************************************
 *
 * $Id$
 *
 * C-Wrapper for GEOS library
 *
 * Copyright (C) 2005 Refractions Research Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation. 
 * See the COPYING file for more information.
 *
 * Author: <NAME> <<EMAIL>>
 *
 ***********************************************************************
 *
 * GENERAL NOTES:
 *
 *	- Remember to call initGEOS() before any use of this library's
 *	  functions, and call finishGEOS() when done.
 *
 *	- Currently you have to explicitly GEOSGeom_destroy() all
 *	  GEOSGeom objects to avoid memory leaks, and to free()
 *	  all returned char * (unless const). This might change
 *	  before first release to ensure greater API stability.
 *
 ***********************************************************************/

 
/************************************************************************
 *
 * (Abstract) type definitions
 *
 ***********************************************************************/

typedef void (*GEOSMessageHandler)(const char *fmt, ...);
typedef struct GEOSGeom *GEOSGeom;

/* Supported geometry types */
enum GEOSGeomTypeId {
	GEOS_POINT,
	GEOS_LINESTRING,
	GEOS_LINEARRING,
	GEOS_POLYGON,
	GEOS_MULTIPOINT,
	GEOS_MULTILINESTRING,
	GEOS_MULTIPOLYGON,
	GEOS_GEOMETRYCOLLECTION
};


/************************************************************************
 *
 * Initializzation, cleanup, version
 *
 ***********************************************************************/

extern void initGEOS(GEOSMessageHandler notice_function,
	GEOSMessageHandler error_function);
extern void finishGEOS(void);
extern const char *GEOSversion();


/************************************************************************
 *
 * Input and Output functions, return NULL on exception.
 *
 ***********************************************************************/

extern GEOSGeom GEOSGeomFromWKT(const char *wkt);
extern char *GEOSGeomToWKT(const GEOSGeom g);

extern GEOSGeom GEOSGeomFromWKB_buf(const char *wkb, size_t size);
extern char *GEOSGeomToWKB_buf(const GEOSGeom g, size_t *size);


/************************************************************************
 *
 * Memory management
 *
 ***********************************************************************/

extern void GEOSGeom_destroy(GEOSGeom g);


/************************************************************************
 *
 * Topology operations - return NULL on exception.
 *
 ***********************************************************************/

extern GEOSGeom GEOSIntersection(GEOSGeom g1, GEOSGeom g2);
extern GEOSGeom GEOSBuffer(GEOSGeom g1,double width, int quadsegs);
extern GEOSGeom GEOSConvexHull(GEOSGeom g1);
extern GEOSGeom GEOSDifference(GEOSGeom g1,GEOSGeom g2);
extern GEOSGeom GEOSSymDifference(GEOSGeom g1,GEOSGeom g2);
extern GEOSGeom GEOSBoundary(GEOSGeom g1);
extern GEOSGeom GEOSUnion(GEOSGeom g1,GEOSGeom g2);
extern GEOSGeom GEOSPointOnSurface(GEOSGeom g1);
extern GEOSGeom GEOSGetCentroid(GEOSGeom g);
extern char *GEOSRelate(const GEOSGeom g1, const GEOSGeom g2);
extern GEOSGeom GEOSPolygonize(GEOSGeom geoms[], unsigned int ngeoms);

/************************************************************************
 *
 *  Binary predicates - return 2 on exception, 1 on true, 0 on false
 *
 ***********************************************************************/

extern char GEOSRelatePattern(const GEOSGeom g1, const GEOSGeom g2,
	const char *pat);
extern char GEOSDisjoint(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSTouches(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSIntersects(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSCrosses(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSWithin(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSContains(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSOverlaps(const GEOSGeom g1, const GEOSGeom g2);
extern char GEOSEquals(const GEOSGeom g1, const GEOSGeom g2);


/************************************************************************
 *
 *  Unary predicate - return 2 on exception, 1 on true, 0 on false
 *
 ***********************************************************************/

extern char GEOSisEmpty(const GEOSGeom g1);
extern char GEOSisValid(const GEOSGeom g1);
extern char GEOSisSimple(const GEOSGeom g1);
extern char GEOSisRing(const GEOSGeom g1);
extern char GEOSHasZ(const GEOSGeom g1);


/************************************************************************
 *
 *  Geometry info
 *
 ***********************************************************************/

extern int       GEOSGeomTypeId(const GEOSGeom g1);
extern int       GEOSGetNumCoordinate(const GEOSGeom g1);
extern int       GEOSGetNumInteriorRings(const GEOSGeom g1);
extern int       GEOSGetSRID(const GEOSGeom g1);
extern int       GEOSGetNumGeometries(const GEOSGeom g1);
extern void      GEOSSetSRID(GEOSGeom g, int SRID);

{'fraction_non_alphanumeric': 0.32117282755951226, 'fraction_numerical': 0.010354170698664603, 'mean_word_length': 6.7299925205684366, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4361364', 'n_tokens_mistral': 3296, 'n_tokens_neox': 2824, 'n_words': 818}