How to use the jsts/org/locationtech/jts/io/GeoJSONReader function in jsts

To help you get started, we’ve selected a few jsts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / mapUtils.js View on Github external
export function transformJSTSGeometry(jstsGeometry, fromSrs, toSrs) {
    // This all seems excessive, however jsts ol3Parser wasn't working with versions
    // "jsts": "~1.4.0" and "openlayers": "~3.19.1", worth revisting in the future.
    const writer = new GeoJSONWriter();
    const geojsonReader = new Reader();
    const ol3GeoJSON = new GeoJSON();
    const geom = (new GeoJSON())
        .readGeometry(writer.write(jstsGeometry)).transform(fromSrs, toSrs);
    return geojsonReader.read(ol3GeoJSON.writeGeometry(geom));
}
github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / mapUtils.js View on Github external
export function isGeoJSONValid(featureCollection) {
    // creates a jsts GeoJSONReader
    const parser = new Reader();
    for (let i = 0; i < featureCollection.features.length; i += 1) {
        // reads in geojson geometry and returns a jsts geometry
        const geom = parser.read(featureCollection.features[i].geometry);
        if (!isValidOp.isValid(geom)) {
            return false;
        }
    }
    return true;
}
github skeate / Leaflet.buffer / src / leaflet.buffer.js View on Github external
this._featureGroup = options.featureGroup;
    this._replacePolyline = options.replacePolylines;
    this._separateBuffer = options.separateBuffer;
    this._bufferStyle = options.bufferStyle;

    if (!(this._featureGroup instanceof L.FeatureGroup)) {
      throw new Error('options.featureGroup must be a L.FeatureGroup');
    }

    this._unbufferedLayerProps = {};

    // Save the type so super can fire,
    // need to do this as cannot do this.TYPE :(
    this.type = L.EditToolbar.Buffer.TYPE;

    this.geoReader = new GeoJSONReader();
    this.geoWriter = new GeoJSONWriter();
  },
github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / mapUtils.js View on Github external
export function convertGeoJSONtoJSTS(geojson, bufferSize, bufferPolys) {
    const geojsonReader = new Reader();

    const jstsGeoJSON = geojsonReader.read(geojson);

    let geometry;
    if (jstsGeoJSON.features) {
        const { features } = jstsGeoJSON;
        geometry = bufferGeometry(features[0].geometry, bufferSize, bufferPolys);
        for (let i = 1; i < features.length; i += 1) {
            geometry = UnionOp.union(
                geometry,
                bufferGeometry(features[i].geometry, bufferSize, bufferPolys),
            );
        }
    } else if (jstsGeoJSON.geometries) {
        const { geometries } = jstsGeoJSON;
        geometry = bufferGeometry(geometries[0], bufferSize, bufferPolys);
github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / mapUtils.js View on Github external
export function bufferGeojson(featureCollection, bufferSize, bufferPolys) {
    const geojsonReader = new Reader();
    const jstsGeoJSON = geojsonReader.read(featureCollection);
    const { features } = jstsGeoJSON;
    const writer = new GeoJSONWriter();
    const bufferedFeatures = [];
    features.forEach((feat) => {
        const size = bufferSize || 1;
        const geom = bufferGeometry(feat.geometry, size, bufferPolys);
        let geojsonGeom;
        if (geom.getArea() !== 0) {
            geojsonGeom = writer.write(geom);
            bufferedFeatures.push({
                type: 'Feature',
                properties: feat.properties || {},
                geometry: { ...geojsonGeom },
            });
        }