1

I am using the GeoServer Importer REST API to import some CSV data to an Oracle database(datastore). This is what I do:

  • create an export task:
curl -XPOST -H "Content-type: application/json" -d @import.json "https://server:8043/geoserver/rest/imports"

{"import": {
  "targetWorkspace": {
     "workspace": {
        "name": "gds"
     }
  },
  "targetStore": {
     "dataStore": {
        "name": "TestData"
     }
  }
} }
  • Define the data:
curl -F name=test -F filedata=@RS_Data.csv "https://server:8043/geoserver/rest/imports/${TASK_ID}/tasks"

Data:Modified sample from the GeoServer manual

ID,AssetID,SampleTime,Lat",Lon,Value
1,1,2015-01-01T10:00:00,10.00,62.00,15.2
2,1,2015-01-01T11:00:00,10.10,62.11,30.25

Output is as follows:

{"layer":{
    "name":"RS_Data",
    "href":"https://server:8043/geoserver/rest/imports/9/tasks/0/layer",
    "title":"RS_Data",
    "originalName":"RS_Data",
    "nativeName":"RS_Data",
    "srs":"EPSG:4326",
    "bbox":{"minx":0,"miny":0,"maxx":-1,"maxy":-1},
    "attributes":[
        {"name":"ID","binding":"java.lang.Integer"},
        {"name":"AssetID","binding":"java.lang.Integer"},            
        {"name":"SampleTime","binding":"java.lang.String"},            
        {"name":"Lat","binding":"java.lang.Double"},
        {"name":"Lon","binding":"java.lang.Double"},
        {"name":"Value","binding":"java.lang.Double"}],"style":
        {"name":"point","href":"https://server:8043/geoserver/rest/imports/9/tasks/0/layer/style"}}}
  • Update CRS:
curl -XPUT -H "Content-type: application/json" -d @updateSRS.json "https://server:8043/geoserver/rest/imports/${TASK_ID}/tasks/0/layer"

the above call works fine:

  • create a transformation mapping the Lat/Lon columns to a point:
curl -XPOST -H "Content-type: application/json" -d @topoint.json "https://server:8043/geoserver/rest/imports/${TASK_ID}/tasks/0/transforms"

Works fine too

  • The import call is as follows:
curl -XPOST "https://server:8043/geoserver/rest/imports/${TASK_ID}"

However, running the task itself yields the following result with error:

{"task":{
    "id":0,
    "href":"https://server:8043/geoserver/rest/imports/9/tasks/0",
    "state":"ERROR",
    "updateMode":"CREATE",
    "data":{"type":"file","format":"CSV","file":"RS_Data.csv"},
    "target":{"href":"https://server:8043/geoserver/rest/imports/9/tasks/0/target",
    "dataStore":{"name":"TestData","type":"Oracle NG (OCI)"}},
    "progress":"https://server:8043/geoserver/rest/imports/9/tasks/0/progress",
    "layer":{"name":"RS_DATA0","href":"https://server:8043/geoserver/rest/imports/9/tasks/0/layer"},
    "errorMessage":"FeatureType http://www.opengis.net/gml:RS_DATA0 does not have lat lng fields named 'Lat' and 'Lon'",
    "transformChain":{"type":"vector","transforms":[
        {"type":"AttributesToPointGeometryTransform","href":"https://server:8043/geoserver/rest/imports/9/tasks/0/transforms/0"}]}}}

Checking from Geoserver Webinterface, I get the following error:

java.lang.Exception: FeatureType http://www.opengis.net/gml:RS_DATA0 does not have lat lng fields named 'Lat' and 'Lon'
at org.geoserver.importer.transform.AttributesToPointGeometryTransform.apply(AttributesToPointGeometryTransform.java:56)
at org.geoserver.importer.transform.VectorTransformChain.inline(VectorTransformChain.java:41)
at org.geoserver.importer.Importer.loadIntoDataStore(Importer.java:1189)
at org.geoserver.importer.Importer.doIndirectImport(Importer.java:970)
at org.geoserver.importer.Importer.run(Importer.java:831)
at org.geoserver.importer.Importer.run(Importer.java:781)
at org.geoserver.importer.Importer.run(Importer.java:755)
at org.geoserver.importer.Importer.run(Importer.java:751)
...

I really can't figure out what's the problem, and I can't seem to find anything from the forum. The importer plugin documentation itself is rather thin.

Any Help?

1

The CSV should be:

ID,AssetID,SampleTime,Lat,Lon,Value 1,1,2015-01-01T10:00:00,10.00,62.00,15.2 2,1,2015-01-01T11:00:00,10.10,62.11,30.25

Written like you have it, there is an extra double quote that might make the parser think you have an attribute named ,Lon,Value (although it would be better if the code just threw an exception at the un-closed double quote)

  • Thanks for the reply. However, even removing the double quote does not solve it. I had inserted the double quotes hoping that it was not interpreting the lat lon column names as strings. BTW, I tried with other datasets but to no avail. What beats me is that, i have one particular CSV file that seems to work fine. – algone Jan 15 '16 at 8:26
  • The problem still persists. While trying to find a solution, I checked the versions of my importer plugin and compared it to the Geoserver version. Turns out that I was using version 2.8.0 of Geoserver against 2.8.1 of the importer extension. So I moved to Geoserver 2.8.1, but no change, ...still the importer cant find the lat lon even though they are there. Could the problem be on the db side? Am using an Oracle OCI datastore – algone Jan 20 '16 at 16:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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