georender-pack
Advanced tools
Comparing version 4.2.3 to 4.2.4
var getNormals = require('polyline-normals') | ||
var varint = require('varint') | ||
var makeEdgeGraph = require('./lib/makeEdgeGraph.js') | ||
var getLoops = require('./lib/get-loops.js') | ||
@@ -29,6 +29,6 @@ module.exports = function (buffers) { | ||
offset+=varint.decode.bytes | ||
sizes.line.types+=plen*2+2 | ||
sizes.line.ids+=plen*2+2 | ||
sizes.line.positions+=plen*4+4 | ||
sizes.line.normals+=plen*4+4 | ||
sizes.line.types+=plen*2+3 | ||
sizes.line.ids+=plen*2+3 | ||
sizes.line.positions+=plen*4+6 | ||
sizes.line.normals+=plen*4+6 | ||
} | ||
@@ -242,14 +242,5 @@ else if (featureType === 3) { | ||
} | ||
var edgeGraph = makeEdgeGraph(cells) | ||
var start = 0 | ||
for (var j=0; j<positions.length; j++) { | ||
var a = j | ||
var b = (j+1)%positions.length | ||
var ab = a + ',' + b | ||
if ((ab !== '0,1' && edgeGraph[ab] !==1) || j === positions.length-1) { | ||
var pos = positions.slice(start, j+1) | ||
if (pos.length === 0) continue | ||
start = j+1 | ||
addAreaBorderPositions(data, offsets, pos, id, type) | ||
} | ||
var loops = getLoops(cells, positions) | ||
for (var i=0; i <loops.length; i++) { | ||
addAreaBorderPositions(data, offsets, loops[i], id, type, false) | ||
} | ||
@@ -292,3 +283,3 @@ pindex+=plen | ||
if (e === 0) { // edge break | ||
addAreaBorderPositions(data, offsets, positions, id, type) | ||
addAreaBorderPositions(data, offsets, positions, id, type, false) | ||
positions = [] | ||
@@ -314,3 +305,3 @@ } else if (e % 2 === 0) { // edge index | ||
} | ||
addAreaBorderPositions(data, offsets, positions, id, type) | ||
addAreaBorderPositions(data, offsets, positions, id, type, false) | ||
pindex+=plen | ||
@@ -320,2 +311,7 @@ offset = decodeLabels(buf, offset, data.area, id) | ||
} | ||
if (offsets.areaBorder.types !== data.areaBorder.types.length) { | ||
data.areaBorder.types = data.areaBorder.types.subarray(0, offsets.areaBorder.types) | ||
data.areaBorder.positions = data.areaBorder.positions.subarray(0, offsets.areaBorder.positions) | ||
data.areaBorder.normals = data.areaBorder.normals.subarray(0, offsets.areaBorder.normals) | ||
} | ||
return data | ||
@@ -337,3 +333,3 @@ } | ||
function addAreaBorderPositions(data, offsets, positions, id, type) { | ||
function addAreaBorderPositions(data, offsets, positions, id, type, closed) { | ||
if (positions.length < 2) return | ||
@@ -359,3 +355,3 @@ var positionsCount = 2+6+(4*positions.length) | ||
} | ||
var normals = getNormals(positions, false) | ||
var normals = getNormals(positions, closed) | ||
var scale = Math.sqrt(normals[0][1]) | ||
@@ -362,0 +358,0 @@ data.areaBorder.ids[offsets.areaBorder.ids++] = id |
{ | ||
"name": "georender-pack", | ||
"version": "4.2.3", | ||
"version": "4.2.4", | ||
"description": "pack and unpack osm data based on the peermaps buffer schema", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78418
2548