Hi all,
I'd like to programmatically add layers from a PostGIS DB to a locally running GeoServer instance by using the REST API. Now I'm struggling to publish the PostGIS table "stand_manual" in the existing DataStore "venue" as a new layer via the REST API.
I issue this request first for creating the FeatureType:
POST
http://localhost:8151/geoserver/rest/workspaces/default_workspace/datastores/venue/featuretypes
with the following XML content
<featureType>
<enabled>true</enabled>
<metadata />
<keywords><string>KEYWORD</string></keywords
<projectionPolicy>REPROJECT_TO_DECLARED</projectionPolicy>
<title>stand_manual</title>
<name>stand_manual</name>
<srs>EPSG:32632</srs>
</featureType>
Afterwards the layer itself is created with another request.
No direct errors occur, and the layer appears in the web interface afterwards. But when I check its details, the native SRS field is empty. Both the computation of the native bounds and a click on the "Publish" tab fails and leads to an error saying
java.lang.IllegalArgumentException: Argument "sourceCRS" should not be null
When I publish the layer via the web interface, everything works fine as expected.
Why can't the API detect the SRS of the PostGIS table, while the web interface can?
Any ideas on what could go wrong here? Any epxerienced API users?
Thanks in advance!
Cheers,
Matthias
Hi again,
I solved the problem. In the whole inconvenient XML jungle you have to deal with I just overlooked the fact that additionally to the <srs> tag there is also the <nativeCRS> tag which *must* be set in order to have the layer being published properly. After I added that tag it worked.
All the best,
Matthias
Am 21.11.2012 15:35, schrieb Matthias Uden:
Hi all,
I'd like to programmatically add layers from a PostGIS DB to a locally
running GeoServer instance by using the REST API. Now I'm struggling to
publish the PostGIS table "stand_manual" in the existing DataStore
"venue" as a new layer via the REST API.
I issue this request first for creating the FeatureType:
POST
http://localhost:8151/geoserver/rest/workspaces/default_workspace/datastores/venue/featuretypes
with the following XML content
<featureType>
<enabled>true</enabled>
<metadata />
<keywords><string>KEYWORD</string></keywords
<projectionPolicy>REPROJECT_TO_DECLARED</projectionPolicy>
<title>stand_manual</title>
<name>stand_manual</name>
<srs>EPSG:32632</srs>
</featureType>
Afterwards the layer itself is created with another request.
No direct errors occur, and the layer appears in the web interface
afterwards. But when I check its details, the native SRS field is empty.
Both the computation of the native bounds and a click on the "Publish"
tab fails and leads to an error saying
java.lang.IllegalArgumentException: Argument "sourceCRS" should not be null
When I publish the layer via the web interface, everything works fine as
expected.
Why can't the API detect the SRS of the PostGIS table, while the web
interface can?
Any ideas on what could go wrong here? Any epxerienced API users?
Thanks in advance!
Cheers,
Matthias
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
On Fri, Nov 23, 2012 at 2:21 PM, Matthias Uden <matthias.uden@anonymised.com.> wrote:
Hi again,
I solved the problem. In the whole inconvenient XML jungle you have to
deal with I just overlooked the fact that additionally to the tag
there is also the tag which must be set in order to have
the layer being published properly. After I added that tag it worked.
Thanks for letting us know.
As a rule of thumb, when in need of writing something, do so once by using
the GUI, check what XML results by looking at the REST results for that
resource, and the mimick it when calling REST in order to add a similar
resource automatically
Cheers
Andrea
–
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it