/** * @module org/locationtech/jts/io/GeoJSONReader */ import GeometryFactory from '../geom/GeometryFactory' import GeoJSONParser from './GeoJSONParser' /** * Converts a geometry in GeoJSON to a {@link Geometry}. */ export default class GeoJSONReader { /** * A GeoJSONReader is parameterized by a GeometryFactory, * to allow it to create Geometry objects of the appropriate * implementation. In particular, the GeometryFactory determines * the PrecisionModel and SRID that is used. * * @param {GeometryFactory} geometryFactory */ constructor(geometryFactory) { this.parser = new GeoJSONParser(geometryFactory || new GeometryFactory()) } /** * Reads a GeoJSON representation of a {@link Geometry} * * Will also parse GeoJSON Features/FeatureCollections as custom objects. * * @param {Object|String} geoJson a GeoJSON Object or String. * @return {Geometry|Object} a Geometry or Feature/FeatureCollection representation. * @memberof module:org/locationtech/jts/io/GeoJSONReader# */ read(geoJson) { const geometry = this.parser.read(geoJson) return geometry } }