Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const jsts_validate = function(geom) {
if (geom instanceof jsts.geom.Polygon) {
if (geom.isValid()) {
geom.normalize() // validate does not pick up rings in the wrong order - this will fix that
return geom // If the polygon is valid just return it
}
var polygonizer = new jsts.operation.polygonize.Polygonizer()
jsts_addPolygon(geom, polygonizer)
return jsts_toPolygonGeometry(polygonizer.getPolygons(), geom.getFactory())
} else if (geom instanceof jsts.geom.MultiPolygon) {
if (geom.isValid()) {
geom.normalize() // validate does not pick up rings in the wrong order - this will fix that
return geom // If the multipolygon is valid just return it
}
var polygonizer = new jsts.operation.polygonize.Polygonizer()
for (var n = geom.getNumGeometries(); n > 0; n--) {
jsts_addPolygon(geom.getGeometryN(n - 1), polygonizer)
var fs = require("fs"),
util = require("util");
var async = require("async"),
connect = require("connect"),
pg = require("pg"),
request = require("request"),
jsts = require("jsts");
var factory = new jsts.geom.GeometryFactory();
var reader = new jsts.io.WKTReader(factory);
var zerocount = 0,
nonzerocount = 0,
undefcount = 0,
existscount = 0;
var startPostgresClient = function(callback) {
// postgres
var client = new pg.Client({
user: "",
user: "openspaces",
//user: "ggnpc",
password: "",
database: "openspaces",
//database: "ggnpc",
// filter out unneccessary downloads
var newOsmBoundarySources = {}
Object.keys(zoneCfg).forEach((zoneName) => {
zoneCfg[zoneName].forEach((op) => {
if (op.source === 'overpass') {
newOsmBoundarySources[op.id] = osmBoundarySources[op.id]
}
})
})
osmBoundarySources = newOsmBoundarySources
}
var geoJsonReader = new jsts.io.GeoJSONReader()
var geoJsonWriter = new jsts.io.GeoJSONWriter()
var precisionModel = new jsts.geom.PrecisionModel(1000000)
var precisionReducer = new jsts.precision.GeometryPrecisionReducer(precisionModel)
var distZones = {}
var minRequestGap = 4
var curRequestGap = 4
var safeMkdir = function (dirname, callback) {
fs.mkdir(dirname, function (err) {
if (err && err.code === 'EEXIST') {
callback()
} else {
callback(err)
}
})
}
var debugGeo = function (op, a, b, reducePrecision) {
const jsts_validate = function(geom) {
if (geom instanceof jsts.geom.Polygon) {
if (geom.isValid()) {
geom.normalize() // validate does not pick up rings in the wrong order - this will fix that
return geom // If the polygon is valid just return it
}
var polygonizer = new jsts.operation.polygonize.Polygonizer()
jsts_addPolygon(geom, polygonizer)
return jsts_toPolygonGeometry(polygonizer.getPolygons(), geom.getFactory())
} else if (geom instanceof jsts.geom.MultiPolygon) {
if (geom.isValid()) {
geom.normalize() // validate does not pick up rings in the wrong order - this will fix that
return geom // If the multipolygon is valid just return it
}
var polygonizer = new jsts.operation.polygonize.Polygonizer()
for (var n = geom.getNumGeometries(); n > 0; n--) {
jsts_addPolygon(geom.getGeometryN(n - 1), polygonizer)
}
return jsts_toPolygonGeometry(polygonizer.getPolygons(), geom.getFactory())
} else {
return geom // In my case, I only care about polygon / multipolygon geometries
}
}
const checkOverlap = (feature1, feature2) => {