We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The LinearRing is not a "complete" type in OpenLayers, and cannot be rendered on a map. (See http://openlayers.org/en/master/apidoc/ol.geom.LinearRing.html)
LinearRing
It would be useful to pass an argument to the OL3Parser instructing it to generate an OpenLayers LineString from LinearRing inputs.
OL3Parser
LineString
The text was updated successfully, but these errors were encountered:
I have created the following workaround some time ago and had no troubles so far.
import GeometryFactory from 'jsts/org/locationtech/jts/geom/GeometryFactory.js' import OL3Parser from 'jsts/org/locationtech/jts/io/OL3Parser.js' import GeoJSONReader from 'jsts/org/locationtech/jts/io/GeoJSONReader.js' import * as geom from 'ol/geom.js' export { GeoJSONReader } const K = v => fn => { fn(v); return v } const geometryFactory = new GeometryFactory() /** * Setup JST/OL parser to convert between JST and OL geometries. * REFERENCE: http://bjornharrtell.github.io/jsts/1.6.1/doc/module-org_locationtech_jts_io_OL3Parser.html */ const parser = K(new OL3Parser(geometryFactory))(parser => parser.inject( geom.Point, geom.LineString, geom.LinearRing, geom.Polygon, geom.MultiPoint, geom.MultiLineString, geom.MultiPolygon, geom.GeometryCollection )) /** * JSTS ignores the fact that ol.geom.LinearRing is not supposed to be rendered. * We convert LinearRing to equivalent LineString. */ /* eslint-disable no-proto */ const convertToLinearRing = parser.__proto__.convertToLinearRing parser.__proto__.convertToLinearRing = function (linearRing) { const geometry = convertToLinearRing.call(this, linearRing) return new geom.LineString(geometry.getCoordinates()) } export const read = olGeometry => parser.read(olGeometry) export const write = jtsGeometry => parser.write(jtsGeometry)
Sorry, something went wrong.
No branches or pull requests
The
LinearRing
is not a "complete" type in OpenLayers, and cannot be rendered on a map. (See http://openlayers.org/en/master/apidoc/ol.geom.LinearRing.html)It would be useful to pass an argument to the
OL3Parser
instructing it to generate an OpenLayersLineString
fromLinearRing
inputs.The text was updated successfully, but these errors were encountered: