예제 #1
0
파일: rgeos.c 프로젝트: imclab/rgeos
SEXP rgeos_GEOSversion(void) {

    SEXP ans = NEW_CHARACTER(1);
    SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING(GEOSversion()));

    return(ans);
}
예제 #2
0
Handle<FunctionTemplate> Geometry::MakeGeometryTemplate()
{
    HandleScope scope;
    Handle<FunctionTemplate> t = FunctionTemplate::New(New);
    Local<ObjectTemplate> obj_t = t->InstanceTemplate();
    obj_t->SetInternalFieldCount(1);
    obj_t->Set(String::NewSymbol("_geosVersion"), String::New(GEOSversion()));
    obj_t->SetAccessor(String::NewSymbol("envelope"), GetEnvelope);
    obj_t->SetAccessor(String::NewSymbol("convexHull"), GetConvexHull);
    obj_t->SetAccessor(String::NewSymbol("boundary"), GetBoundary);
    obj_t->SetAccessor(String::NewSymbol("pointOnSurface"), GetPointOnSurface);
    obj_t->SetAccessor(String::NewSymbol("centroid"), GetCentroid);
    obj_t->SetAccessor(String::NewSymbol("srid"), GetSRID, SetSRID);
    obj_t->SetAccessor(String::NewSymbol("type"), GetType);
    obj_t->SetAccessor(String::NewSymbol("area"), GetArea);
    obj_t->SetAccessor(String::NewSymbol("length"), GetLength);
    return scope.Close(t);
}
예제 #3
0
const char*
lwgeom_geos_version()
{
	const char *ver = GEOSversion();
	return ver;
}
예제 #4
0
int
run_all_testcases (struct db_conn *conn, int load_extension)
{
    int ret;
    int result = 0;
    const char *security_level;

    result = run_subdir_test ("sql_stmt_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }

    security_level = getenv ("SPATIALITE_SECURITY");
    if (security_level == NULL)
	;
    else if (strcasecmp (security_level, "relaxed") == 0)
      {
	  result =
	      run_subdir_test ("sql_stmt_security_tests", conn, load_extension);
	  if (result != 0)
	    {
		return result;
	    }
      }

#ifndef OMIT_MATHSQL		/* only if MATHSQL is supported */
    result = run_subdir_test ("sql_stmt_mathsql_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }
#endif /* end MATHSQL conditional */

#ifndef OMIT_PROJ		/* only if PROJ is supported */
    result = run_subdir_test ("sql_stmt_proj_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }
#endif /* end PROJ conditional */

#ifndef OMIT_GEOS		/* only if GEOS is supported */
    if (strcmp (GEOSversion (), "3.3") < 0)
      {
	  /* 
	     skipping GEOS tests if some obsolete version is found 

	     rationale: obsolete versions may return substantially
	     different results, thus causing many testcases to fail
	   */
	  fprintf (stderr,
		   "WARNING: skipping GEOS testcases; obsolete version found !!!\n");
	  goto skip_geos;
      }
    ret = system ("cp test_geos.sqlite test_geos_x.sqlite");
    if (ret != 0)
      {
	  fprintf (stderr, "cannot copy test_geos database\n");
	  return -1;
      }

    result = run_subdir_test ("sql_stmt_geos_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }

    ret = unlink ("test_geos_x.sqlite");
    if (ret != 0)
      {
	  fprintf (stderr, "cannot remove test_geos_x database\n");
	  return -20;
      }
  skip_geos:
#endif /* end GEOS conditional */

#ifdef GEOS_ADVANCED		/* only if GEOS_ADVANCED is supported */
    if (strcmp (GEOSversion (), "3.4") < 0)
      {
	  /* 
	     skipping GEOS tests if some obsolete version is found 

	     rationale: obsolete versions may return substantially
	     different results, thus causing many testcases to fail
	   */
	  fprintf (stderr,
		   "WARNING: skipping GEOS_ADVANCED testcases; obsolete version found !!!\n");
	  goto skip_geos_advanced;
      }

    result =
	run_subdir_test ("sql_stmt_geosadvanced_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }

  skip_geos_advanced:
#endif /* end GEOS_ADVANCED conditional */

#ifdef ENABLE_LWGEOM		/* only if LWGEOM is supported */
    result = run_subdir_test ("sql_stmt_lwgeom_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }

#endif /* end LWGEOM conditional */

#ifdef ENABLE_LIBXML2		/* only if LIBXML2 is supported */
    result = run_subdir_test ("sql_stmt_libxml2_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }

    security_level = getenv ("SPATIALITE_SECURITY");
    if (security_level == NULL)
	;
    else if (strcasecmp (security_level, "relaxed") == 0)
      {
	  result =
	      run_subdir_test ("sql_stmt_libxml2_tests", conn, load_extension);
	  if (result != 0)
	    {
		return result;
	    }
      }

#endif /* end LIBXML2 conditional */

#ifdef ENABLE_GEOPACKAGE	/* only if GeoPackage support is enabled */
    result =
	run_subdir_test ("sql_stmt_geopackage_tests", conn, load_extension);
    if (result != 0)
      {
	  return result;
      }

#endif /* end GEOPACKAGE conditional */

    return result;
}
예제 #5
0
static void geom_func_register(sqlite3 *db, errorstream_t *error, geos_context_t *ctx) {
  char const *geos_version = GEOSversion(ctx->geos_handle);
  int geos_major;
  int geos_minor;
  int geos_version_result = sscanf(geos_version, "%d.%d", &geos_major, &geos_minor);
  if (geos_version_result != 2) {
    error_append(error, "Could not parse GEOS version number (%s)", geos_version);
  }

  GEOS_FUNCTION(db, ST, Area, 1, ctx, error);
  GEOS_FUNCTION4(db, "ST_Length", ST_Length, GEOSLength_r, 1, ctx, error);
  GEOS_FUNCTION4(db, "GLength", ST_Length, GEOSLength_r, 1, ctx, error);

  GEOS_FUNCTION2(db, ST, IsSimple, isSimple, 1, ctx, error);
  GEOS_FUNCTION2(db, ST, IsRing, isRing, 1, ctx, error);
  GEOS_FUNCTION2(db, ST, IsValid, isValid, 1, ctx, error);

  GEOS_FUNCTION_PREP(db, ST, Disjoint, 2, ctx, error);
  GEOS_FUNCTION_PREP(db, ST, Intersects, 2, ctx, error);
  GEOS_FUNCTION_PREP(db, ST, Touches, 2, ctx, error);
  GEOS_FUNCTION_PREP(db, ST, Crosses, 2, ctx, error);
  GEOS_FUNCTION_PREP(db, ST, Within, 2, ctx, error);
  GEOS_FUNCTION_PREP(db, ST, Contains, 2, ctx, error);
  GEOS_FUNCTION_PREP(db, ST, Overlaps, 2, ctx, error);
  GEOS_FUNCTION(db, ST, Equals, 2, ctx, error);
  GEOS_FUNCTION2(db, ST, Relate, RelatePattern, 3, ctx, error);

  GEOS_FUNCTION(db, ST, Distance, 2, ctx, error);
  GEOS_FUNCTION(db, ST, HausdorffDistance, 2, ctx, error);

  GEOS_FUNCTION(db, ST, Boundary, 1, ctx, error);
  GEOS_FUNCTION(db, ST, ConvexHull, 1, ctx, error);
  GEOS_FUNCTION(db, ST, Envelope, 1, ctx, error);

  GEOS_FUNCTION(db, ST, Difference, 2, ctx, error);
  GEOS_FUNCTION(db, ST, SymDifference, 2, ctx, error);
  GEOS_FUNCTION(db, ST, Intersection, 2, ctx, error);
  GEOS_FUNCTION4(db, "ST_Union", ST_Union, GEOSUnion_r, 2, ctx, error);
  GEOS_FUNCTION4(db, "GUnion", ST_Union, GEOSUnion_r, 2, ctx, error);

  GEOS_FUNCTION(db, ST, Buffer, 2, ctx, error);

  GEOS_FUNCTION2(db, ST, Centroid, GetCentroid, 1, ctx, error);

  GEOS_FUNCTION2(db, ST, NumPoints, GeomGetNumPoints, 1, ctx, error);
  GEOS_FUNCTION2(db, ST, PointN, GeomGetPointN, 2, ctx, error);
  GEOS_FUNCTION2(db, ST, StartPoint, GeomGetStartPoint, 1, ctx, error);
  GEOS_FUNCTION2(db, ST, EndPoint, GeomGetEndPoint, 1, ctx, error);

  GEOS_FUNCTION2(db, ST, NumInteriorRings, GetNumInteriorRings, 1, ctx, error);
  GEOS_FUNCTION2(db, ST, InteriorRingN, GetInteriorRingN, 2, ctx, error);
  GEOS_FUNCTION2(db, ST, ExteriorRing, GetExteriorRing, 1, ctx, error);

  GEOS_FUNCTION2(db, ST, NumGeometries, GetNumGeometries, 1, ctx, error);
  GEOS_FUNCTION2(db, ST, GeometryN, GetGeometryN, 2, ctx, error);

#if GPKG_GEOM_FUNC == GPKG_GEOS_DL || (GEOS_VERSION_MAJOR > 3 || (GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 3))
  if (geos_major > 3 || (geos_major == 3 && geos_minor >= 3)) {
    GEOS_FUNCTION2(db, ST, IsClosed, isClosed, 1, ctx, error);
    GEOS_FUNCTION_PREP(db, ST, Covers, 2, ctx, error);
    GEOS_FUNCTION_PREP(db, ST, CoveredBy, 2, ctx, error);
  }
#endif

  GEOS_FUNCTION3(db, GPKG, GEOSVersion, GEOSversion, 0, ctx, error);
}
예제 #6
0
static void GPKG_GEOSVersion(sqlite3_context *context, int nbArgs, sqlite3_value **args) {
  const geos_context_t *geos_context = (const geos_context_t *)sqlite3_user_data(context);
  sqlite3_result_text(context, GEOSversion(geos_context->geos_handle), -1, SQLITE_TRANSIENT);
}