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

Adds a constant to check GeoJSON RFC7946 testing and building #239

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

jsanz
Copy link
Member

@jsanz jsanz commented Dec 28, 2021

Related to #231

This PR adds a new constant GEOJSON_RFC7946, set to undefined at this moment to not change the current results of tests and build, leaving the definition of this behavior for a follow-up PR when discussion in #231 is concluded.

When set to true to enforce the RFC7946 standard for polygon orientation in GeoJSON files, the build process will ensure that all published polygons in all data layers are counter-clockwise oriented. When testing with EMS_STRICT_TEST env var defined, it will report which data layers are not following the standard.

When set to false it will build all polygons clockwise oriented and with EMS_STRICT_TEST it will report the data layers that follow the RFC7946 standard and are being rewind'ed in the build process.

Screenshots of test executions with EMS_STRICT_TEST

GEOJSON_RFC7946 = undefined

no changes in build and test results:

undefined


GEOJSON_RFC7946 = true

There are 62 files that are not following the standard.

enforce


GEOJSON_RFC7946 = false

There are 20 files that follow the standard and are consequently reported by the tests.

neglect

@kibanamachine
Copy link

💚 Build Succeeded

Copy link
Member

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! this is a good implementation that will make it easy to enforce depending on the conclusion of #231

const reader = new jsts.io.GeoJSONReader();
const fc = reader.read(geojson);
const fieldsNames = fieldMap.map(f => f.name).sort();
t.ok(fc.features.every(feat => feat.geometry.isSimple()
), 'All geometries must be simple');
), `All geometries from ${fileName} must be simple`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the fileName is very helpful. Thank you!

@jsanz jsanz merged commit 00ce928 into elastic:master Jan 5, 2022
@jsanz jsanz deleted the rfc7946 branch January 5, 2022 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants