[Geoserver-users] CSV data source gives error [SEC=UNOFFICIAL]

Hi

If I have a test CSV file as follows

ID,Lon,Lat

1,120.1,-35.2

And use the CSV Vector Data Source, choosing ‘guess’ as the strategy, on trying to create the Layer you get the following error:

Failed to load attribute list, internal error is: the SimpleFeatureType test:test does not contains the configured attribute Lon. Check your schema configuration

It seems at the below point in the code the layer tries to load the feature type with each property based on the list of attributes found in the CSV

https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java#L1078

But in GeoTools the Lat/Lon columns are removed on encoding of the Point class, which means the feature type does not have the attributes GeoServer is looking for

https://github.com/geotools/geotools/blob/master/modules/plugin/csv/src/main/java/org/geotools/data/csv/parse/CSVLatLonStrategy.java#L121

I’m not sure where this bug resides. Part of me thinks that the Lat/Lon fields shouldn’t be dropped when parsing a CSV, as they hold useful human-readable information. But I don’t know the internal logic of GeoTools all that well compared to GeoServer.

Anyway, I haven’t been able to get CSVs working with GeoServer 2.18.1, and any help would be appreciated.

Thanks

Michael

That’s a bit odd - I’ve just tested the GeoTools code and it is fine loading a CSV with only id,lat and lon columns. So there is presumably something in GeoServer that is expecting a non-spatial attribute to be left after it’s ignored the ID column, Can you raise a bug and I’ll see if I can find some time to look at it next weekend or over christmas?

Ian

···

Ian Turton

Thanks Ian

I have filed the bug here

https://osgeo-org.atlassian.net/browse/GEOS-9827

Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks.

···

Michael Sexton


From: Ian Turton ijturton@anonymised.com
Sent: Monday, 30 November 2020 9:48 PM
To: Sexton Michael Michael.Sexton@anonymised.com
Cc: geoserver-users@lists.sourceforge.net geoserver-users@anonymised.comsourceforge.net
Subject: Re: [Geoserver-users] CSV data source gives error [SEC=UNOFFICIAL]

That’s a bit odd - I’ve just tested the GeoTools code and it is fine loading a CSV with only id,lat and lon columns. So there is presumably something in GeoServer that is expecting a non-spatial attribute to be left after it’s ignored the ID column, Can you raise a bug and I’ll see if I can find some time to look at it next weekend or over christmas?

Ian

On Mon, 30 Nov 2020 at 06:24, Sexton Michael <Michael.Sexton@anonymised.com.174…> wrote:

Hi

If I have a test CSV file as follows

ID,Lon,Lat

1,120.1,-35.2

And use the CSV Vector Data Source, choosing ‘guess’ as the strategy, on trying to create the Layer you get the following error:

Failed to load attribute list, internal error is: the SimpleFeatureType test:test does not contains the configured attribute Lon. Check your schema configuration

It seems at the below point in the code the layer tries to load the feature type with each property based on the list of attributes found in the CSV

https://github.com/geoserver/geoserver/blob/master/src/main/src/main/java/org/geoserver/catalog/ResourcePool.java#L1078

But in GeoTools the Lat/Lon columns are removed on encoding of the Point class, which means the feature type does not have the attributes GeoServer is looking for

https://github.com/geotools/geotools/blob/master/modules/plugin/csv/src/main/java/org/geotools/data/csv/parse/CSVLatLonStrategy.java#L121

I’m not sure where this bug resides. Part of me thinks that the Lat/Lon fields shouldn’t be dropped when parsing a CSV, as they hold useful human-readable information. But I don’t know the internal logic of GeoTools all that well compared to GeoServer.

Anyway, I haven’t been able to get CSVs working with GeoServer 2.18.1, and any help would be appreciated.

Thanks

Michael

Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks.


Geoserver-users mailing list

Please make sure you read the following two resources before posting to this list:

If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ian Turton