Changeset: f37a250af6e1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/f37a250af6e1
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom_atoms.c
geom/monetdb5/geom_atoms.h
geom/sql/functions/Tests/ST_Transform.test
Branch: geo-update
Log Message:
Adds early bailout in case of same SRID Transform
diffs (106 lines):
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -655,7 +655,11 @@ wkbTransform(wkb **transformedWKB, wkb *
throw(MAL, "geom.Transform", SQLSTATE(38000) "Cannot find in
spatial_ref_sys srid %d\n", *srid_src);
if (strcmp(*proj4_dst_str, "null") == 0)
throw(MAL, "geom.Transform", SQLSTATE(38000) "Cannot find in
spatial_ref_sys srid %d\n", *srid_dst);
-
+ if (strcmp(*proj4_src_str, *proj4_dst_str) == 0) {
+ if ((*transformedWKB = wkbCopy(*geomWKB)) == NULL)
+ throw(MAL, "geom.Transform", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ return MAL_SUCCEED;
+ }
//Create PROJ transformation object with PROJ strings passed as argument
P = proj_create_crs_to_crs(PJ_DEFAULT_CTX,
*proj4_src_str,
diff --git a/geom/monetdb5/geom_atoms.c b/geom/monetdb5/geom_atoms.c
--- a/geom/monetdb5/geom_atoms.c
+++ b/geom/monetdb5/geom_atoms.c
@@ -223,6 +223,18 @@ wkbNULLcopy(void)
return n;
}
+wkb *
+wkbCopy(const wkb* src)
+{
+ wkb *n = GDKmalloc(wkb_size(src->len));
+ if (n) {
+ n->len = src->len;
+ n->srid = src->srid;
+ memcpy(n->data, src->data, src->len);
+ }
+ return n;
+}
+
/* returns the size of variable-sized atom wkb */
var_t
wkb_size(size_t len)
diff --git a/geom/monetdb5/geom_atoms.h b/geom/monetdb5/geom_atoms.h
--- a/geom/monetdb5/geom_atoms.h
+++ b/geom/monetdb5/geom_atoms.h
@@ -22,6 +22,7 @@ size_t wkbLENGTH(const void *P);
gdk_return wkbHEAP(Heap *heap, size_t capacity);
/* Non-atom WKB functions */
wkb * wkbNULLcopy(void);
+wkb * wkbCopy(const wkb* src);
var_t wkb_size(size_t len);
str wkbFROMSTR_withSRID(const char *geomWKT, size_t *len, wkb **geomWKB, int
srid, size_t *nread);
diff --git a/geom/sql/functions/Tests/ST_Transform.test
b/geom/sql/functions/Tests/ST_Transform.test
--- a/geom/sql/functions/Tests/ST_Transform.test
+++ b/geom/sql/functions/Tests/ST_Transform.test
@@ -1,39 +1,46 @@
-# Point from 4026 to 3035 query T rowsort
+# Point from 4326 to 4326
+query T rowsort
+SELECT ST_AsText(ST_Transform(st_setsrid(st_pointfromtext('POINT (-4.4657183
48.38249)'), 4326), 4326))
+----
+POINT (-4.4657183 48.38249)
+
+# Point from 4326 to 3035
+query T rowsort
SELECT ST_AsText(ST_Transform(st_setsrid(st_pointfromtext('POINT (-4.4657183
48.38249)'), 4326), 3035))
----
POINT (3256910.236847341 2912495.415279291)
-# MultiPoint from 4026 to 3035
+# MultiPoint from 4326 to 3035
query T rowsort
SELECT ST_AsText(ST_Transform(st_setsrid(st_geomfromtext('MULTIPOINT
(-4.4657183 48.38249, -4.4965715 48.38242, -4.644325 48.092247, -4.4851084
48.38132, -4.4954414 48.38366, -4.347825 48.117958, -4.7691517 47.987152,
-4.4719133 48.16634, -4.782632 48.005634, -4.46572 48.382507)'), 4326), 3035))
----
MULTIPOINT (3256910.236847341 2912495.415279291, 3254672.923283204
2912934.464415785, 3237755.624311555 2883346.764096317, 3255480.25560844
2912648.02021654, 3254781.139009903 2913053.766874474, 3259904.442835956
2881843.115747155, 3226399.412122162 2873698.514442336, 3251885.335621446
2888932.855248591, 3225814.1034443 2875919.873412735, 3256910.473817608
2912497.300134167)
-# Linestring from 4026 to 3035
+# Linestring from 4326 to 3035
query T rowsort
SELECT ST_AsText(ST_Transform(st_setsrid(st_linefromtext('LINESTRING
(-5.6873484 48.344147, -5.6681333 48.33428, -5.6679835 48.33422, -5.66766
48.33412)'), 4326), 3035))
----
LINESTRING (3167671.816827851 2926719.292472556, 3168833.765553358
2925341.353047237, 3168843.214508454 2925332.458495204, 3168864.297833474
2925316.477595154)
-# MultiLinestring from 4026 to 3035
+# MultiLinestring from 4326 to 3035
query T rowsort
SELECT ST_AsText(ST_Transform(st_setsrid(st_geomfromtext('MULTILINESTRING
((-5.6873484 48.344147, -5.6681333 48.33428), (-5.6681333 48.33428, -5.6679835
48.33422), (-5.6679835 48.33422, -5.66766 48.33412))'), 4326), 3035))
----
MULTILINESTRING ((3167671.816827851 2926719.292472556, 3168833.765553358
2925341.353047237), (3168833.765553358 2925341.353047237, 3168843.214508454
2925332.458495204), (3168843.214508454 2925332.458495204, 3168864.297833474
2925316.477595154))
-# Polygon from 4026 to 3035
+# Polygon from 4326 to 3035
query T rowsort
SELECT ST_AsText(ST_Transform(st_setsrid(st_polygonfromtext('POLYGON ((-70 35,
-70 39, -65 39, -65 35, -70 35))'), 4326), 3035))
----
POLYGON ((-1551336.688637011 4960140.610519264, -1181855.207118743
5226023.370006166, -1007637.697308938 4831052.145729965, -1359624.178799202
4542397.806396248, -1551336.688637011 4960140.610519264))
-# MultiPolygon from 4026 to 3035
+# MultiPolygon from 4326 to 3035
query T rowsort
SELECT ST_AsText(ST_Transform(st_setsrid(st_geomfromtext('MULTIPOLYGON (((-20
-50, -20 -40, 30 -40, 30 -50, -20 -50)), ((30 -50, 30 -45, 40 -45, 40 -50, 30
-50)))'), 4326), 3035))
----
MULTIPOLYGON (((951463.5890125036 -6309234.415106328, 687127.3565636296
-5482088.556344701, 6760173.911872292 -5732283.768352984, 6581741.604272356
-6509599.735591641, 951463.5890125036 -6309234.415106328)), ((6581741.604272356
-6509599.735591641, 6682271.808015617 -6128844.200428242, 7839821.83702993
-5902264.746195812, 7690536.410987496 -6309234.415106328, 6581741.604272356
-6509599.735591641)))
-# GeometryCollection from 4026 to 3035
+# GeometryCollection from 4326 to 3035
# TODO: Not yet supported
#query T rowsort
#SELECT ST_AsText(ST_Transform(st_setsrid(st_geomfromtext('GEOMETRYCOLLECTION
(POLYGON ((-20 -50, -20 -40, 30 -40, 30 -50, -20 -50)), POLYGON ((30 -50, 30
-45, 40 -45, 40 -50, 30 -50)), MULTIPOINT (-4.4657183 48.38249, -4.4965715
48.38242, -4.644325 48.092247))'), 4326), 3035))
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]