0

I try to upload (create) on to GeoServer layers with different CRSes, possible unknown for GeoServer (and not presented in user_projections/epsg.properties). First I do this, for example:

c:\OSGeo4W\bin\ogr2ogr.exe -skipfailures -f PostgreSQL PG:"dbname='dbgis' host='localhost' port='5432' user='postgres' password='123456'" "be32d51207af4b1a8d0cf6163c282274.mif"

Then I do this:

C:\curl\bin\curl.exe -u admin:123456 -XPOST -H "Content-type: text/xml" -d "<featureType><name>be32d51207af4b1a8d0cf6163c282274</name></featureType>" http://localhost:8080/geoserver/rest/workspaces/a77x7/datastores/PostGis/featuretypes

And this:

C:\curl\bin\curl.exe -u admin:123456 -XPUT -H "Content-type: application/xml" -d "<layer><enabled>true</enabled></layer>" http://localhost:8080/geoserver/rest/layers/be32d51207af4b1a8d0cf6163c282274

But setting CRS failed:

C:\curl\bin\curl.exe -u admin:123456 -XPUT -H "Content-type: application/xml" -d @"...\crs.xml" http://localhost:8080/geoserver/rest/workspaces/a77x7/datastores/PostGis/featuretypes/be32d51207af4b1a8d0cf6163c282274

Where crs.xml is (by gdalsrsinfo -o wkt ...), for example:

<featureType><enabled>true</enabled><nativeCRS>
PROJCS["unnamed",GEOGCS["unnamed",DATUM["Pulkovo_1942",SPHEROID["Krassovsky",6378245,298.3],TOWGS84[24,-123,-94,0.02,-0.25,-0.13,1.1]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",75],PARAMETER["scale_factor",1],PARAMETER["false_easting",13500000],PARAMETER["false_northing",0],UNIT["Meter",1.0]]
</nativeCRS><srs>EPSG:4326</srs><projectionPolicy>NONE</projectionPolicy></featureType>

GeoServer says "200 OK", but projectionPolicy stays FORCE_DECLARED. If I set empty srs tag, GeoServer answer "500 Server Error".

How I can publish layers with any CRS in GeoServer through REST?

By web interface projectionPolicy of NONE not saved too (see images). enter image description here

enter image description here

1

I partially solved a problem... If I create featuretype on GeoServer for PostGIS table as one single step then CRS sets as I expected: Instead of second step of:

C:\curl\bin\curl.exe -u admin:123456 -XPOST -H "Content-type: text/xml" -d "<featureType><name>be32d51207af4b1a8d0cf6163c282274</name></featureType>" http://localhost:8080/geoserver/rest/workspaces/a77x7/datastores/PostGis/featuretypes

I send xml file with full info about feature type:

C:\curl\bin\curl.exe -u admin:123456 -XPOST -H "Content-type: text/xml" -d @"c:\temp\...\be32d51207af4b1a8d0cf6163c282274.a77x7_ftx" http://localhost:8080/geoserver/rest/workspaces/a77x7/datastores/PostGis/featuretypes

Where a77x7_ftx is a my extension of xml file, for example:

<featureType><name>be32d51207af4b1a8d0cf6163c282274</name><enabled>true</enabled><nativeCRS>PROJCS["unnamed",GEOGCS["unnamed",DATUM["Pulkovo_1942",SPHEROID["Krassovsky",6378245,298.3],TOWGS84[24,-123,-94,0.02,-0.25,-0.13,1.1]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",75],PARAMETER["scale_factor",1],PARAMETER["false_easting",13500000],PARAMETER["false_northing",0],UNIT["Meter",1.0]]
</nativeCRS><projectionPolicy>NONE</projectionPolicy></featureType>

And fourth step not needed (as in my original post):

C:\curl\bin\curl.exe -u admin:123456 -XPUT -H "Content-type: application/xml" -d @"...\crs.xml" http://localhost:8080/geoserver/rest/workspaces/a77x7/datastores/PostGis/featuretypes/be32d51207af4b1a8d0cf6163c282274

As result GeoServer recognizes native CRS and set it as declared (see image): enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.