Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osm2geojson-lite

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osm2geojson-lite - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

lib/polytags.json

20

lib/index.js

@@ -48,7 +48,7 @@ const {Node, Way, Relation} = require('./osmobjs.js'),

xmlParser.addListener('<osm.relation>', node => {
new Relation(node.$id, refElements);
xmlParser.on('<osm.relation>', node => {
new Relation(node.$id, refElements);
});
xmlParser.addListener('</osm.way>', node => {
xmlParser.on('</osm.way>', node => {
with (node) {

@@ -68,3 +68,3 @@ let way = new Way($id, refElements);

xmlParser.addListener('</osm.node>', node => {
xmlParser.on('</osm.node>', node => {
with (node) {

@@ -79,10 +79,4 @@ let nd = new Node($id, refElements);

xmlParser.addListener('<osm.relation>', (node, parent) => {
xmlParser.on('</osm.relation.member>', (node, parent) => {
with (node) {
new Relation($id, refElements);
}
});
xmlParser.addListener('</osm.relation.member>', (node, parent) => {
with (node) {
let relation = refElements[parent.$id];

@@ -123,5 +117,5 @@ let member = {

xmlParser.addListener('</osm.relation.bounds>', (node, parent) => refElements[parent.$id].addProperty('bbox', [parseFloat(node.$minlon), parseFloat(node.$minlat), parseFloat(node.$maxlon), parseFloat(node.$maxlat)]));
xmlParser.on('</osm.relation.bounds>', (node, parent) => refElements[parent.$id].addProperty('bbox', [parseFloat(node.$minlon), parseFloat(node.$minlat), parseFloat(node.$maxlon), parseFloat(node.$maxlat)]));
xmlParser.addListener('</osm.relation.tag>', (node, parent) => {
xmlParser.on('</osm.relation.tag>', (node, parent) => {
refElements[parent.$id].addTag(node.$k, node.$v)

@@ -128,0 +122,0 @@ });

@@ -5,3 +5,4 @@ module.exports = (() => {

isRing, ringDirection, ptInsidePolygon, strToFloat,
LateBinder, WayCollection} = require('./utils.js');
LateBinder, WayCollection} = require('./utils.js'),
polygonTags = require('./polytags.json');

@@ -80,2 +81,3 @@ class OsmObject {

this.coordsArray = [];
this.isPolygon = false;
}

@@ -97,5 +99,24 @@

analyzeTag(k, v) {
let o = polygonTags[k];
if (o) {
this.isPolygon = true;
if (o.whitelist) this.isPolygon = o.whitelist.indexOf(v) >= 0? true : false;
else if(o.blacklist) this.isPolygon = o.blacklist.indexOf(v) >= 0? false : true;
// console.log(`${k}: ${v} => way/${this.id} is a polygon: ${this.isPolygon}`);
}
}
addTags(tags) {
super.addTags(tags);
for (let [k, v] of Object.entries(tags))
this.analyzeTag(k, v);
}
addTag(k, v) {
super.addTag(k, v);
this.analyzeTag(k, v);
}
bindRefs() {
// for (let nd of this.coordsArray)
// if (nd instanceof LateBinder) nd.bind();
this.coordsArray.reduce((a, v) => v instanceof LateBinder? a.concat([v]) : a, []).forEach(lb => lb.bind());

@@ -112,3 +133,3 @@ }

if (this.coordsArray.length > 1) {
if (isRing(this.coordsArray)) {
if (this.isPolygon && isRing(this.coordsArray)) {
if (ringDirection(this.coordsArray) !== 'counterclockwise') this.coordsArray.reverse();

@@ -115,0 +136,0 @@ return {

@@ -25,3 +25,3 @@ module.exports = (() => {

let isRing = a => (a.length > 2 && coordsToKey(first(a)) === coordsToKey(last(a)));
let isRing = a => a.length > 2 && coordsToKey(first(a)) === coordsToKey(last(a));

@@ -79,3 +79,3 @@ let ringDirection = (a, xIdx, yIdx) => {

[].splice.apply(this.container, args);
} else if (typeof o === 'object') {
} else if (typeof this.container === 'object') {
let k = Object.keys(this.container).find(v => this.container[v] === this);

@@ -82,0 +82,0 @@ if (k)

@@ -55,3 +55,3 @@ {

},
"version": "0.4.1",
"version": "0.4.2",
"directories": {

@@ -58,0 +58,0 @@ "lib": "lib",

@@ -37,3 +37,3 @@ osm2geojson-lite

### `osm2geojson(osm_xml, opts)`
### `osm2geojson(osm, opts)`

@@ -40,0 +40,0 @@ Converts OSM data (XML/JSON) to GeoJSON.

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