[postgis-devel] more fun on Ultrasparc, unfortunately...

Alex Mayrhofer axelm-postgis at nona.net
Wed Nov 30 03:49:20 PST 2005


strk at refractions.net wrote:
> Please do, transform() tests are completely missing.
> BTW, if you do it against the HEAD branch that would be
> nice (a way to test it as well).

Here we go, this is for the 1.0 branch atm, HEAD will follow tonight.

Minor rounding differences could influence some of the tests on different 
math implementations - what is the policy here?

alex
-------------- next part --------------

-- some transform() regression

-- prime spatial_ref_sys table with two projections

--- EPSG 32633 : WGS 84 / UTM zone 33N
INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (32633,'EPSG',32633,'PROJCS["WGS 84 / UTM zone 33N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",15],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32633"]]','+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ');
--- EPSG 4326 : WGS 84
INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (4326,'EPSG',4326,'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');

--- test #0: NULL values
SELECT 0,coalesce(AsText(transform(NULL, 32633)),'EMPTY');

--- test #1: a simple projection
SELECT 1,AsEWKT(transform(GeomFromEWKT('SRID=4326;POINT(16 48)'),32633));

--- test #2: same in 3D
SELECT 2,AsEWKT(transform(GeomFromEWKT('SRID=4326;POINT(16 48 171)'),32633));

--- test #3: same in 4D
SELECT 3,AsEWKT(transform(GeomFromEWKT('SRID=4326;POINT(16 48 171 -500)'),32633));

--- test #4: LINESTRING projection, 2 points
SELECT 4,AsEWKT(transform(GeomFromEWKT('SRID=4326;LINESTRING(16 48, 16 49)'),32633));

--- test #5: LINESTRING projection, 2 points, 4D
SELECT 5,AsEWKT(transform(GeomFromEWKT('SRID=4326;LINESTRING(16 48 0 0, 16 49 0 0)'),32633));

--- test #6: re-projecting a projected value
SELECT 6,round(X(transform(transform(GeomFromEWKT('SRID=4326;POINT(16 48)'),32633), 4326))::numeric,8),round(Y(transform(transform(GeomFromEWKT('SRID=4326;POINT(16 48)'),32633), 4326))::numeric,8);
-------------- next part --------------
#!/bin/sh

if [ -z "$TMPDIR" ]; then
	TMPDIR=/tmp
fi

OUTFILE="${TMPDIR}/regress_proj_out$$"

echo "Running PROJ Regression Test..."
echo "Output file is: '${OUTFILE}'"
echo 
echo "       expected:'<'     obtained:'>'"
echo

DB=postgis_reg
createdb $DB > /dev/null
createlang plpgsql $DB > /dev/null
psql -f ../lwpostgis.sql $DB > /dev/null 2>&1
psql -tA < regress_proj.sql $DB 2>&1 | grep -v INSERT > "${OUTFILE}"
diff regress_proj_expected "${OUTFILE}"
sleep 1
dropdb $DB > /dev/null
-------------- next part --------------
0|EMPTY
1|SRID=32633;POINT(574595.112486041 5316784.0092365)
2|SRID=32633;POINT(574595.112486041 5316784.0092365 171)
3|SRID=32633;POINT(574595.112486041 5316784.0092365 171 -500)
4|SRID=32633;LINESTRING(574595.112486041 5316784.0092365,573142.012282727 5427937.52346616)
5|SRID=32633;LINESTRING(574595.112486041 5316784.0092365 0 0,573142.012282727 5427937.52346616 0 0)
6|16.00000000|48.00000000


More information about the postgis-devel mailing list