How to use the jsts/org/locationtech/jts/io/GeoJSONWriter 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 skeate / Leaflet.buffer / src / leaflet.buffer.js View on Github external
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 jstsGeomToOlGeom(jstsGeom) {
    const writer = new GeoJSONWriter();
    const olReader = new GeoJSON();
    const olGeom = olReader.readGeometry(writer.write(jstsGeom)).transform('EPSG:4326', 'EPSG:3857');
    return olGeom;
}
github EventKit / eventkit-cloud / eventkit_cloud / ui / static / ui / app / utils / mapUtils.js View on Github external
export function jstsToFeatureCollection(jsts) {
    const writer = new GeoJSONWriter();
    const geom = writer.write((jsts));
    if (geom.coordinates) {
        return {
            type: 'FeatureCollection',
            features: [
                {
                    type: 'Feature',
                    properties: {},
                    geometry: geom,
                },
            ],
        };
    }
    return null;
}
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 },
            });
        }
    });
    const bufferedFeatureCollection = {
        type: 'FeatureCollection',
github bjornharrtell / flatgeobuf / src / ts / geojson.spec.ts View on Github external
function makeFeatureCollectionFromArray(wkts: string[], properties?: any) {
  const reader: any = new WKTReader()
  const writer: any = new GeoJSONWriter()
  const geometries = wkts.map(wkt => writer.write(reader.read(wkt)))
  const features = geometries.map(geometry => ({ type: 'Feature', geometry } as IGeoJsonFeature))
  if (properties)
    features.forEach(f => f.properties = properties)
  return {
    type: 'FeatureCollection',
    features,
  }
}