0.0.2 • Published 10 years ago

geojson2schema v0.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

GeoJSON2Schema

NPM

Introduction

The GeoJSON2Schema package converts valid GeoJSON objects to Schema.org compatible geo objects. As Schema.org doesn't support all GeoJSON features, this package aims to return the best possible Schema.org alternatives.

Installation

Install GeoJSON2Schema using NPM:

npm install geojson2schema

Options

OptionTypeDescription
geoJsonobjectThe GeoJSON object (required)
tolerancefloatTolerance level for the simplify-geometry package, which simplifies (Multi)Polygons using the Ramer–Douglas–Peucker algorithm (optional, defaults to 0)

Usage

var geoJson2schema = require('geojson2schema');
var geoJsonObject = {
  "type": "GeometryCollection",
  "geometries": [
    {
      "type": "Point",
      "coordinates": [100.0, 0.0]
    },
    {
      "type": "LineString",
      "coordinates": [
        [101.0, 0.0],
        [102.0, 1.0]
      ]
    }
  ]
};

var schemaGeometry = geoJson2schema({
  "geoJson": geoJsonObject
});

The example above will create the following schemaGeometry:

[
  {
    "@type": "GeoCoordinates",
    "latitude": 0,
    "longitude": 100
  },
  {
    "@type": "GeoShape",
    "line": "0,101 1,102"
  }
]

Note that Point, Polygon and LineString return objects instead of arrays, as these geometries always map to a single object.

License

ISC License. See the LICENSE file.

0.0.2

10 years ago

0.0.1

10 years ago