Package de.fhpotsdam.unfolding.geo

Examples of de.fhpotsdam.unfolding.geo.Location


   * @param useLargestForMulti
   *            Set to true if you want to use only the largest feature for {@link MultiFeature}s.
   * @return The location of the geometric center.
   */
  public static Location getCentroid(Feature feature, boolean useLargestForMulti) {
    Location location = null;

    switch (feature.getType()) {
    case POINT:
      location = ((PointFeature) feature).getLocation();
      break;
    case LINES:
    case POLYGON:
      location = GeoUtils.getCentroid(((ShapeFeature) feature).getLocations());
      break;
    case MULTI:
      MultiFeature multiFeature = ((MultiFeature) feature);
      if (useLargestForMulti) {
        // Return centroid of largest feature
        Feature largestFeature = getLargestFeature(multiFeature);
        location = getCentroid(largestFeature);

      } else {

        // Return centroid of all features
        List<Location> locations = new ArrayList<Location>();
        for (Feature f : multiFeature.getFeatures()) {
          Location l = getCentroid(f);
          locations.add(l);
        }
        location = GeoUtils.getCentroid(locations);
      }
      break;
View Full Code Here


   * @param locations
   *            List of locations to get the bounding box for.
   * @return An array of two locations consisting of the north-west and the south-east bounds.
   */
  public static Location[] getBoundingBox(List<Location> locations) {
    Location nwLocation = new Location(GeoUtils.MIN_LAT, GeoUtils.MAX_LON);
    Location seLocation = new Location(GeoUtils.MAX_LAT, GeoUtils.MIN_LON);

    for (Location location : locations) {
      if (location.getLat() > nwLocation.getLat()) {
        nwLocation.setLat(location.getLat());
      }
      if (location.getLon() < nwLocation.getLon()) {
        nwLocation.setLon(location.getLon());
      }

      if (location.getLat() < seLocation.getLat()) {
        seLocation.setLat(location.getLat());
      }
      if (location.getLon() > seLocation.getLon()) {
        seLocation.setLon(location.getLon());
      }
    }

    return new Location[] { nwLocation, seLocation };
  }
View Full Code Here

        shift += 5;
      } while (b >= 0x20);
      int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
      lng += dlng;

      Location p = new Location((double) lat * precisionMult, (double) lng * precisionMult);
      poly.add(p);
    }
    return poly;
  }
View Full Code Here

  public void setup() {
    size(800, 600, OPENGL);

    map = new UnfoldingMap(this, "map");
    map.zoomToLevel(4);
    map.panTo(new Location(50f, 12f));
    MapUtils.createDefaultEventDispatcher(this, map);

    SimplePolygonMarker franceMarker = new SimplePolygonMarker(getFranceShapeLocations());
    SimplePolygonMarker corsicaMarker = new SimplePolygonMarker(getCorsicaShapeLocations());
View Full Code Here

  }

  public static List<Location> getFranceShapeLocations() {
    // Crude shape of France
    List<Location> franceLocations = new ArrayList<Location>();
    franceLocations.add(new Location(48.985985f, 8.173828f));
    franceLocations.add(new Location(51.074539f, 2.460938f));
    franceLocations.add(new Location(49.33085f, -0.043945f));
    franceLocations.add(new Location(48.522426f, -4.746094f));
    franceLocations.add(new Location(46.231533f, -1.054687f));
    franceLocations.add(new Location(43.427392f, -1.801758f));
    franceLocations.add(new Location(42.397499f, 3.208008f));
    franceLocations.add(new Location(43.682174f, 3.911133f));
    franceLocations.add(new Location(43.075308f, 6.28418f));
    franceLocations.add(new Location(43.935879f, 7.734375f));
    franceLocations.add(new Location(46.534681f, 6.064453f));
    return franceLocations;
  }
View Full Code Here

  }

  public static List<Location> getCorsicaShapeLocations() {
    // Crude shape of Corsica
    List<Location> corsicaLocations = new ArrayList<Location>();
    corsicaLocations.add(new Location(41.380106f, 9.162598f));
    corsicaLocations.add(new Location(42.231771f, 8.547363f));
    corsicaLocations.add(new Location(42.991791f, 9.404297f));
    corsicaLocations.add(new Location(42.052556f, 9.558105f));
    return corsicaLocations;
  }
View Full Code Here

  public void draw() {
    // Distance in km, appropriate to current zoom
    float distance = MAX_DISPLAY_DISTANCE / map.getZoom();
    distance = getClosestDistance(distance);

    Location startLocation = null;
    Location destLocation = null;
    if (showDistanceAtEquator) {
      // Get destLocation (world center, on equator, with calculated distance)
      startLocation = new Location(0, 0);
      destLocation = GeoUtils.getDestinationLocation(startLocation, 90f, distance);
    } else {
      startLocation = map.getLocation(p.width / 2, p.height / 2);
      destLocation = GeoUtils.getDestinationLocation(startLocation, 90f, distance);
    }
View Full Code Here

   *            The latitude value.
   * @param lon
   *            The longitude value.
   */
  public void addLocation(float lat, float lon) {
    locations.add(new Location(lat, lon));
  }
View Full Code Here

   * This uses marker.getLocation() which either returns single location, or centroid location (of shape marker), and
   * then combines it. TODO Check whether to use {@link GeoUtils#getCentroid(List)} instead.
   */
  @Override
  public Location getLocation() {
    Location center = new Location(0, 0);
    for (Marker marker : markers) {
      center.add(marker.getLocation());
    }
    center.div((float) markers.size());
    return center;
  }
View Full Code Here

  public void setup() {
    size(600, 400, OPENGL);

    map = new UnfoldingMap(this, 0, 0, 400, 400, new StamenMapProvider.WaterColor());
    map.zoomAndPanTo(new Location(51.507222, -0.1275), 10);

    MapUtils.createDefaultEventDispatcher(this, map);
  }
View Full Code Here

TOP

Related Classes of de.fhpotsdam.unfolding.geo.Location

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.