Socket
Socket
Sign inDemoInstall

geojsonhint

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojsonhint - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

bin/.tern-port

63

index.js

@@ -8,4 +8,15 @@ var jsonlint = require('jsonlint-lines');

function root(_) {
if (!_.type) return 'The type member is required and was not found';
types[_.type](_);
if (!_.type) {
errors.push({
message: 'The type member is required and was not found',
line: _.__line__
});
} else if (!types[_.type]) {
errors.push({
message: 'The type ' + _.type + ' is unknown',
line: _.__line__
});
} else {
types[_.type](_);
}
}

@@ -45,3 +56,3 @@

// http://geojson.org/geojson-spec.html#positions
function position(_) {
function position(_, line) {
if (!Array.isArray(_)) {

@@ -51,3 +62,3 @@ return errors.push({

' instead',
line: _.__line__
line: _.__line__ || line
});

@@ -58,3 +69,3 @@ } else {

message: 'position must have 2 or more elements',
line: _.__line__
line: _.__line__ || line
});

@@ -67,3 +78,3 @@ }

message: 'each element in a position must be a number',
line: _.__line__
line: _.__line__ || line
});

@@ -74,2 +85,22 @@ }

function positionArray(coords, depth, line) {
if (line === undefined && coords.__line__ !== undefined) {
line = coords.__line__;
}
if (depth === 0) {
return position(coords, line);
} else {
if (!Array.isArray(coords)) {
return errors.push({
message: 'coordinates should be an array, are an ' + (typeof coords) +
'instead',
line: line
});
}
coords.forEach(function(c) {
positionArray(c, depth - 1, c.__line__ || line);
});
}
}
// http://geojson.org/geojson-spec.html#point

@@ -83,15 +114,23 @@ function Point(_) {

function Polygon(_) {
requiredProperty(_, 'coordinates', 'array');
if (!requiredProperty(_, 'coordinates', 'array')) {
positionArray(_.coordinates, 2);
}
}
function MultiPolygon(_) {
requiredProperty(_, 'coordinates', 'array');
if (!requiredProperty(_, 'coordinates', 'array')) {
positionArray(_.coordinates, 3);
}
}
function LineString(_) {
requiredProperty(_, 'coordinates', 'array');
if (!requiredProperty(_, 'coordinates', 'array')) {
positionArray(_.coordinates, 1);
}
}
function MultiLineString(_) {
requiredProperty(_, 'coordinates', 'array');
if (!requiredProperty(_, 'coordinates', 'array')) {
positionArray(_.coordinates, 2);
}
}

@@ -101,3 +140,5 @@

function MultiPoint(_) {
requiredProperty(_, 'coordinates', 'array');
if (!requiredProperty(_, 'coordinates', 'array')) {
positionArray(_.coordinates, 1);
}
}

@@ -104,0 +145,0 @@

9

package.json
{
"name": "geojsonhint",
"version": "0.0.0",
"version": "0.1.0",
"description": "validate and sanity-check geojson files",

@@ -14,2 +14,5 @@ "main": "index.js",

},
"bin": {
"geojsonhint": "./bin/geojsonhint"
},
"scripts": {

@@ -32,4 +35,6 @@ "test": "mocha -R spec"

"dependencies": {
"jsonlint-lines": "~1.6.0"
"jsonlint-lines": "~1.6.0",
"optimist": "~0.6.0",
"colors": "~0.6.0-1"
}
}

@@ -16,6 +16,10 @@ [![Build Status](https://secure.travis-ci.org/tmcw/geojsonhint.png?branch=master)](http://travis-ci.org/tmcw/geojsonhint)

npm install geojsonhint
# as a binary
npm install -g geojsonhint
# as a library
npm install --save geojsonhint
## See Also
[geojsonlint.com](http://geojsonlint.com/) does this server-side
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc