Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geojson is being rounded #96

Closed
albertwgchu opened this issue Jan 29, 2019 · 4 comments
Closed

geojson is being rounded #96

albertwgchu opened this issue Jan 29, 2019 · 4 comments
Labels

Comments

@albertwgchu
Copy link

Found an issue where geojson being sent to ElasticSearch is being rounded to 4 digits.

After taking a look at the code the issue is that GeometryJSON defaults to 4 decimal places if there's no value passed to the constructor.

This line is the issue:
FilterToElastic.java final String geoJson = new GeometryJSON().toString(currentGeometry);

// this will give 8 decimal places
FilterToElastic.java final String geoJson = new GeometryJSON(8).toString(currentGeometry);

Geoserver has a setting for "Maximum number of decimals", does it make sense to use this value?

@sjudeng
Copy link
Contributor

sjudeng commented Jan 30, 2019

Thank you for reporting this issue and taking the time to track down the cause. Definitely a bug.

It looks like "max number of decimals" refers to precision in GML output? Here it's the precision of the serialized geometry that's used when making queries, so it's a little different. How about instead we use the JTS PecisionModel for floats (e.g. 16)? It's what JTS uses when serializing to WKT so it seems reasonable here.

final PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
final int decimalPlaces = precisionModel.getMaximumSignificantDigits();
final String geoJson = new GeometryJSON(decimalPlaces).toString(currentGeometry);

@sjudeng sjudeng added the bug label Jan 30, 2019
@albertwgchu
Copy link
Author

That sounds great to me. We noticed this bug when making wfs requests at low zooms. Will it be included in the next release?

@sjudeng
Copy link
Contributor

sjudeng commented Jan 30, 2019

Yes we'll make sure to get this fixed in the next release. Thanks again for reporting.

@sjudeng
Copy link
Contributor

sjudeng commented Mar 1, 2019

This fix is included in the new release candidate 2.14.2-RC1.

@sjudeng sjudeng closed this as completed Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants