Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
action: function() {
const input = prompt("Enter your Hex encoded WKB/EWKB");
try {
var decoded = wkx.Geometry.parse(Buffer.from(input, "hex"));
setGeojson(decoded.toGeoJSON());
// zoomextent(context); TODO
} catch (e) {
console.error(e);
alert(
"Sorry, we were unable to decode that Hex encoded WKX data"
);
}
}
},
if (version !== GeoPackageConstants.GEOPACKAGE_GEOMETRY_VERSION_1) {
throw new Error('Unexpected GeoPackage Geometry version ' + version + ', Expected: ' + GeoPackageConstants.GEOPACKAGE_GEOMETRY_VERSION_1);
}
var flags = buffer.readUInt8(3);
var envelopeIndicator = this.readFlags(flags);
this.srsId = buffer[this.byteOrder ? 'readUInt32LE' : 'readUInt32BE'](4);
var envelopeAndOffset = this.readEnvelope(envelopeIndicator, buffer);
this.envelope = envelopeAndOffset.envelope;
var offset = envelopeAndOffset.offset;
var wkbBuffer = buffer.slice(offset);
try {
this.geometry = wkx.Geometry.parse(wkbBuffer);
this.geometryError = undefined;
} catch (error) {
this.geometryError = error.message;
console.log('Error parsing geometry');
}
};
_.forEach(geometry, property => {
this.handleGeometry(wkx.Geometry.parse(property).toGeoJSON())
})
this.updateSelected = _debounce(this.updateSelected, 100, {
_stringify(value, options) {
return `GeomFromText(${options.escape(wkx.Geometry.parseGeoJSON(value).toWkt())})`;
}
_bindParam(value, options) {
static parse(value) {
const b = Buffer.from(value, 'hex');
return wkx.Geometry.parse(b).toGeoJSON();
}
_stringify(value, options) {
if (users[observation.userId]) properties.user = users[observation.userId].username;
if (devices[observation.deviceId]) properties.device = devices[observation.deviceId].uid;
var centroid = turfCentroid(observation);
properties.mgrs = mgrs.forward(centroid.geometry.coordinates);
properties.shapeType = observation.geometry.type;
if (observation.geometry.type === 'Point') {
properties.longitude = observation.geometry.coordinates[0];
properties.latitude = observation.geometry.coordinates[1];
} else {
properties.longitude = centroid.geometry.coordinates[0];
properties.latitude = centroid.geometry.coordinates[1];
}
properties.wkt = wkx.Geometry.parseGeoJSON(observation.geometry).toWkt();
properties.excelTimestamp = "=DATEVALUE(MID(INDIRECT(ADDRESS(ROW(),COLUMN()-1)),1,10)) + TIMEVALUE(MID(INDIRECT(ADDRESS(ROW(),COLUMN()-1)),12,8))";
if (observation.attachments.length > 0) {
properties.attachment = observation.attachments[0].name;
properties.attachmentExcelLink = excelLink(observation.attachments[0], 1);
archive.file(path.join(attachmentBase, observation.attachments[0].relativePath), {name: observation.attachments[0].name});
}
flattened.push(properties);
for (var i = 1; i < observation.attachments.length; i++) {
var attachment = observation.attachments[i];
flattened.push({
id: observation.id,
function checkLonLatOrdering(model){
try {
var test = wkx.Geometry.parse(model.getValue());
return checkGeometryCoordinateOrdering(test.toGeoJSON());
} catch (err){
return false;
}
}
const popupOption = {
closeButton: false,
minWidth: 260,
maxWidth: 300,
maxHeight: 300,
};
var vectorLayer = L.geoJSON([], {
style: geojsonStyle,
pointToLayer: function(feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
},
});
vectorLayer.addTo(mymap);
var polyTest = wkx.Geometry.parse('${geomValue}');
var geoJSON = polyTest.toGeoJSON();
var SRID = geoJSON.selectedSRID;
vectorLayer.addData(geoJSON);
var bounds = vectorLayer.getBounds();
mymap.fitBounds(bounds);
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(mymap);
}
function roundWktCoords(wkt) {
if (!inputIsBlank(wkt) && checkForm(wkt) && checkLonLatOrdering(wkt)) {
let parsed = wkx.Geometry.parse(wkt)
let geoJson = parsed.toGeoJSON()
return createRoundedWktGeo(geoJson)
} else {
return wkt
}
}
function checkForm(model){
try {
var test = wkx.Geometry.parse(model.getValue());
if (test.toWkt() === removeTrailingZeros(convertUserValueToWKT(model.getValue()))) {
return true;
} else {
return false;
}
} catch (err){
return false;
}
}