Package de.fhpotsdam.unfolding.data

Examples of de.fhpotsdam.unfolding.data.ShapeFeature


    if (feature.getType() == Feature.FeatureType.POINT) {
      PointFeature pf = (PointFeature) feature;
      locations.add(pf.getLocation());
    }
    if (feature.getType() == Feature.FeatureType.LINES || feature.getType() == Feature.FeatureType.POLYGON) {
      ShapeFeature sf = (ShapeFeature) feature;
      locations.addAll(sf.getLocations());
    }
    if (feature.getType() == Feature.FeatureType.MULTI) {
      MultiFeature multiFeature = (MultiFeature) feature;
      for (Feature f : multiFeature.getFeatures()) {
        locations.addAll(getLocations(f));
View Full Code Here


    List<Feature> transitLines = GeoJSONReader.loadData(this, "data/MBTARapidTransitLines.json");

    // Create marker from features, and use LINE property to color the markers.
    List<Marker> transitMarkers = new ArrayList<Marker>();
    for (Feature feature : transitLines) {
      ShapeFeature lineFeature = (ShapeFeature) feature;

      SimpleLinesMarker m = new SimpleLinesMarker(lineFeature.getLocations());
      String lineColor = lineFeature.getStringProperty("LINE");
      int color = 0;
      // Original MBTA colors
      if (lineColor.equals("BLUE")) {
        color = color(44, 91, 167);
      }
View Full Code Here

    Calendar prevTime = null;
    Location prevLocation = null;

    // Create track with all track points
    ShapeFeature trackFeature = new ShapeFeature(FeatureType.LINES);
    List<Double> speedList = new ArrayList<Double>();

    XML[] itemXML = gpx.getChildren("trk/trkseg/trkpt");
    for (int i = 0; i < itemXML.length; i++) {

      // Adds location for track point
      float lat = itemXML[i].getFloat("lat");
      float lon = itemXML[i].getFloat("lon");
      Location location = new Location(lat, lon);

      // Calculates speed for track point
      // Uses time span (h) and distance (km) to previous point to get km/h
      double speed = 0;
      try {
        String timeStr = itemXML[i].getChild("time").getContent();
        // Replace "Z" for Zulu/GMT time with parseable hour offset
        timeStr = timeStr.replaceAll("Z", "+0000");
        Calendar time = StringUtils.parseIsoDateTime(timeStr);

        if (prevTime != null) {
          long timeMS = time.getTimeInMillis();
          long timeDiff = timeMS - prevTime.getTimeInMillis();
          double dist = GeoUtils.getDistance(location, prevLocation);
          speed = dist / ((float) timeDiff / 1000 / 60 / 60);
        }

        prevTime = time;
        prevLocation = location;

      } catch (ParseException e) {
        // println("Error:" + e);
      }

      speedList.add(speed);
      trackFeature.addLocation(location);
    }
    trackFeature.putProperty("speedList", speedList);
    trackFeatures.add(trackFeature);

    return trackFeatures;
  }
View Full Code Here

    shapeGroup = createShape(PShape.GROUP);

    for (int i = 0; i < features.size(); i++) {
      Feature feature = features.get(i);
      if (feature.getType().equals(FeatureType.POLYGON)) {
        ShapeFeature shapeFeature = (ShapeFeature) feature;

        updateShape("c" + i, shapeFeature, false);
      }
    }
    return shapeGroup;
View Full Code Here

  public void updateFeatures(List<Feature> features) {
    for (int i = 0; i < features.size(); i++) {
      Feature feature = features.get(i);
      if (feature.getType().equals(FeatureType.POLYGON)) {
        ShapeFeature shapeFeature = (ShapeFeature) feature;
       
        updateShape("c" + i, shapeFeature, true);
      }
    }
View Full Code Here

  }

  public List<PVector> simplifyFeature(Feature feature) {
    List<PVector> simplifiedPoints = new ArrayList<PVector>();
    if (feature instanceof ShapeFeature) {
      ShapeFeature shapeFeature = (ShapeFeature) feature;

      List<PVector> points = getPositions(shapeFeature.getLocations());
      simplifiedPoints = GeneralizationUtils.simplify(points, tolerance, true);
    }
    return simplifiedPoints;
  }
View Full Code Here

TOP

Related Classes of de.fhpotsdam.unfolding.data.ShapeFeature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.