I am receiving GML as part of a larger XML message. When I receive the XML it is unmarshalled to Java objects. I have no rights to alter the schemas or the generated Java code. Therefore, I later have to marshal the OpenGIS polygon back to XML. When I try to store it in the PostGIS database, I get the following exception:
org.postgresql.util.PSQLException: ERROR: unknown spatial reference system
This is my query:
INSERT INTO test (polygon) VALUES (ST_GeomFromGML('
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:Polygon srsName="http://metadata.ces.mil/mdr/ns/GSIP/crs/WGS84E_3D" ns1:id="P1" xmlns:ns6="http://www.isotc211.org/2005/gts" xmlns:ns5="http://release.niem.gov/niem/external/ogc/xls/1.1.0/dhs-gmo/2.1.0" xmlns:ns2="http://www.w3.org/1999/xlink" xmlns:ns1="http://www.opengis.net/gml/3.2" xmlns:ns4="http://www.isotc211.org/2005/gmd" xmlns:ns3="http://www.isotc211.org/2005/gco">
<ns1:exterior>
<ns1:LinearRing>
<ns1:pos>32.23426 -110.34511 90.2</ns1:pos>
<ns1:pos>32.23435 -110.34544 90.2</ns1:pos>
<ns1:pos>32.23444 -110.34555 90.2</ns1:pos>
<ns1:pos>32.23426 -110.34511 90.2</ns1:pos>
</ns1:LinearRing>
</ns1:exterior>
</ns1:Polygon>', 4326))
If I try to remove the SRID from the query, I get the same exception. The column I try to store the polygon in, looks like this:
AddGeometryColumn('test', 'polygon', 4326, 'POLYGON', 3);
Any ideas? Please let me know if you need any more information.
<gml:posList srsDimension="3">0 0 0 0 0 1 0 1 1 0 1 0 0 0 0</gml:posList>
, ie, with a srsDimension. I accept that this might seem unlikely from the error message, but worth checking. – John Powell Apr 28 '16 at 10:12srsDimension="3"
, but it didn't help. However, I found out that if I change the srsName tosrsName="EPSG:4269"
it works. I could override that attribute, but I will try to fix it otherwise first. – fossecode Apr 28 '16 at 10:50net.opengis.gml._3.PolygonType
, do you have any idea on how I can convert it to a JTS polygon? – fossecode Apr 28 '16 at 10:52