halestudio / hale

(Spatial) data harmonisation with hale»studio (formerly HUMBOLDT Alignment Editor)
147 stars 44 forks source link

[BUG]: When exporting a GeoJSON with ElementType BigDecimal, value is exported in quotation marks #1248

Open JohannaOtt opened 2 months ago

JohannaOtt commented 2 months ago

Describe the bug When exporting a GeoJSON file for a schema based on an xsd defining an element as BigDecimal, the values are exported with quotation marks.

To Reproduce Check the transformation provided in this forum thread.

Expected behavior There should be no quotation marks when exporting the data as GeoJSON.

Possible workaround: As a workaround it should be possible to use a schema that uses an actual geometry binding and let the writer encode it as geojson geometry. So defining geometry as a geometry field (using hale GeometryProperty class as binding, directly using JTS Geometry class might also work).

stempler commented 2 months ago

image (1)

Looking at the property definition in the screenshot I don't think the behavior is wrong for the schema definition. hale does not support multi-dimensional arrays or lists of lists as binding at the moment though.

The type is defined as list of BigDecimal but its values seem to be lists of lists of numbers. I would guess what happens is that the list can't be converted to BigDecimal so for writing to Json it resorts to the string representation as fallback.

The workaround with the explicit geometry binding that was mentioned only works in cases where the intent is to create a GeoJson geometry representation, which in the given example seems to be the case.

mgarbula commented 2 months ago

I was the one who raised the ticket. @stempler to understand what you meant - on the screen it can be seen coordinates (0..n) which means that coordinates is an array - is that correct? Then - that array contains lists of BigDecimal and - as you said - hale doesn't support multi-dimensional arrays. So the problem is in the multi-dimensionality of the array - right?

mgarbula commented 2 months ago

@JohannaOtt so how my xsd schema should look like if I wanted to use GeometryProperty class?

stempler commented 2 months ago

@mgarbula If you use an XML schema to define the schema, then you need to use GML types to have a geometry binding in hale.

Here is an example based on your project (zip contains project and exported Json): hale-1248.zip

In the exported Json you can see that MultiLineString is used as geometry type. Not sure if the data may have multiple line strings in the features, that this type is used is because the Shapefile reader creates this kind of geometry.

github-actions[bot] commented 1 week ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in two weeks if no further activity occurs. Thank you for your contributions.

JohannaOtt commented 9 hours ago

As the behavior describe as a bug in the issue description is expected and all questions are clarified, I would like to move on and close this issue. @mgarbula Any objections?