Exemplo n.º 1
0
source.features.map(result => {

    const properties = {
        'waterway': 'stream',
        'source': 'City of Ottawa'
    };

    const stream = turf.lineString(result.geometry.coordinates, properties)
    collection1.features.push(stream);
    console.log("New stream ", collection1.features.length);
});
Exemplo n.º 2
0
  drawBorderedPolygon: function(rectangle) {
    if (!rectangle) {
      // handles case where model changes to empty vars and we don't want to draw anymore
      return
    }
    var lineWidth =
      DistanceUtils.getDistanceInMeters(
        this.model.get('lineWidth'),
        this.model.get('lineUnits')
      ) || 1

    var turfLine = Turf.lineString(
      translateFromOpenlayersCoordinates(rectangle.getCoordinates())
    )
    var bufferedLine = Turf.buffer(turfLine, lineWidth, 'meters')
    var geometryRepresentation = new ol.geom.MultiLineString(
      translateToOpenlayersCoordinates(bufferedLine.geometry.coordinates)
    )

    if (this.vectorLayer) {
      this.map.removeLayer(this.vectorLayer)
    }

    this.billboard = new ol.Feature({
      geometry: geometryRepresentation,
    })

    this.billboard.setId(this.model.cid)

    var color = this.model.get('color')

    var iconStyle = new ol.style.Style({
      stroke: new ol.style.Stroke({
        color: color ? color : '#914500',
        width: 3,
      }),
    })
    this.billboard.setStyle(iconStyle)

    var vectorSource = new ol.source.Vector({
      features: [this.billboard],
    })

    var vectorLayer = new ol.layer.Vector({
      source: vectorSource,
    })

    this.vectorLayer = vectorLayer
    this.map.addLayer(vectorLayer)
  },
Exemplo n.º 3
0
  drawGeometry = model => {
    const json = model.toJSON()
    let linePoints = json.line
    const lineWidth =
      DistanceUtils.getDistanceInMeters(
        json.lineWidth,
        model.get('lineUnits')
      ) || 1
    if (!linePoints) {
      return
    }

    linePoints.forEach(point => {
      point[0] = DistanceUtils.coordinateRound(point[0])
      point[1] = DistanceUtils.coordinateRound(point[1])
    })

    const setArr = _.uniq(linePoints)
    if (setArr.length < 2) {
      return
    }

    const turfLine = Turf.lineString(setArr)
    let bufferedLine = turfLine
    this.cameraMagnitude = this.map.camera.getMagnitude()
    if (lineWidth > 100 || this.cameraMagnitude < CAMERA_MAGNITUDE_THRESHOLD) {
      bufferedLine = Turf.buffer(turfLine, Math.max(lineWidth, 1), 'meters')
    }

    // first destroy old one
    if (this.primitive && !this.primitive.isDestroyed()) {
      this.map.scene.primitives.remove(this.primitive)
    }

    this.primitive = new Cesium.PolylineCollection()
    this.primitive.add(
      this.constructLinePrimitive(bufferedLine.geometry.coordinates)
    )

    this.map.scene.primitives.add(this.primitive)
  }
Exemplo n.º 4
0
function matchesLINESTRING(value, filter) {
    var pointText = filter.value.value.substring(11);
    pointText = pointText.substring(0, pointText.length - 1);
    var lineWidth = filter.distance || 0;
    if (lineWidth <= 0) {
        return false;
    }
    var line = pointText.split(',').map(function (coordinate) {
        return coordinate.split(' ').map(function (value) {
            return Number(value);
        });
    });
    var turfLine = Turf.lineString(line);
    var bufferedLine = Turf.buffer(turfLine, lineWidth, 'meters');
    var polygonToCheck = new Terraformer.Polygon({
        type: 'Polygon',
        coordinates: bufferedLine.geometry.coordinates
    });
    if (intersects(polygonToCheck, value)) {
        return true;
    }
    return false;
}