How to use the wkx.Geometry function in wkx

To help you get started, we’ve selected a few wkx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmcw / geojson.net / src / ui / file_bar.js View on Github external
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"
                );
              }
            }
          },
github ngageoint / geopackage-js / lib / geom / geometryData.js View on Github external
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');
  }
};
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / component / visualization / maps / geometry.view.js View on Github external
_.forEach(geometry, property => {
        this.handleGeometry(wkx.Geometry.parse(property).toGeoJSON())
      })
      this.updateSelected = _debounce(this.updateSelected, 100, {
github dalinhuang99 / betify / node_modules / sequelize / lib / data-types.js View on Github external
_stringify(value, options) {
    return `GeomFromText(${options.escape(wkx.Geometry.parseGeoJSON(value).toWkt())})`;
  }
  _bindParam(value, options) {
github sequelize / sequelize / lib / dialects / postgres / data-types.js View on Github external
static parse(value) {
      const b = Buffer.from(value, 'hex');
      return wkx.Geometry.parse(b).toGeoJSON();
    }
    _stringify(value, options) {
github ngageoint / mage-server / export / csv.js View on Github external
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,
github codice / ddf / catalog / ui / catalog-ui-search / src / main / webapp / component / input / geometry / input-geometry.view.js View on Github external
function checkLonLatOrdering(model){
    try {
        var test = wkx.Geometry.parse(model.getValue());
        return checkGeometryCoordinateOrdering(test.toGeoJSON());
    } catch (err){
        return false;
    }
}
github dbeaver / dbeaver / plugins / org.jkiss.dbeaver.data.gis.view / web / view_template.html View on Github external
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);
        }
github codice / ddf / ui / packages / catalog-ui-search / src / main / webapp / component / location-new / utils / wkt-utils.js View on Github external
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
  }
}
github codice / ddf / catalog / ui / catalog-ui-search / src / main / webapp / component / input / geometry / input-geometry.view.js View on Github external
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;
    }
}

wkx

A WKT/WKB/EWKT/EWKB/TWKB/GeoJSON parser and serializer

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis