GeoJSONWriter.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @module org/locationtech/jts/io/GeoJSONWriter
  3. */
  4. import GeoJSONParser from './GeoJSONParser'
  5. /**
  6. * Writes the GeoJSON representation of a {@link Geometry}. The
  7. * The GeoJSON format is defined <A
  8. * HREF="http://geojson.org/geojson-spec.html">here</A>.
  9. */
  10. export default class GeoJSONWriter {
  11. /**
  12. * The <code>GeoJSONWriter</code> outputs coordinates rounded to the precision
  13. * model. Only the maximum number of decimal places necessary to represent the
  14. * ordinates to the required precision will be output.
  15. *
  16. * @param {GeometryFactory} geometryFactory
  17. * @constructor
  18. */
  19. constructor() {
  20. this.parser = new GeoJSONParser(this.geometryFactory)
  21. }
  22. /**
  23. * Converts a <code>Geometry</code> to its GeoJSON representation.
  24. *
  25. * @param {Geometry}
  26. * geometry a <code>Geometry</code> to process.
  27. * @return {Object} The GeoJSON representation of the Geometry.
  28. * @memberof module:org/locationtech/jts/io/GeoJSONWriter#
  29. */
  30. write(geometry) {
  31. return this.parser.write(geometry)
  32. }
  33. }