Ignore:
Timestamp:
2015-12-15T17:42:22+01:00 (9 years ago)
Author:
floscher
Message:

[proj4j] Implement new method org.openstreetmap.josm.data.projection.Projection.getWorldBoundsBoxEastNorth()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/proj4j/src/org/openstreetmap/josm/plugins/proj4j/Proj4JProjection.java

    r31353 r31830  
    55
    66import org.openstreetmap.josm.data.Bounds;
     7import org.openstreetmap.josm.data.ProjectionBounds;
    78import org.openstreetmap.josm.data.coor.EastNorth;
    89import org.openstreetmap.josm.data.coor.LatLon;
     
    2021    public Proj4JProjection(String crsCode) {
    2122        this.crsCode = crsCode;
    22        
     23
    2324        org.osgeo.proj4j.CRSFactory crsFactory =
    2425                new org.osgeo.proj4j.CRSFactory();
     
    8687
    8788    @Override
     89    public ProjectionBounds getWorldBoundsBoxEastNorth() {
     90      // TODO: Check if this method does, what it should do. For now it's just a workaround to fix the failing build.
     91      // This code is a simplified version of org.openstreetmap.josm.data.projection.AbstractProjection.getWorldBoundsBoxEastNorth()
     92      Bounds b = getWorldBoundsLatLon();
     93      // add 4 corners
     94      ProjectionBounds result = new ProjectionBounds(latlon2eastNorth(b.getMin()));
     95      result.extend(latlon2eastNorth(b.getMax()));
     96      result.extend(latlon2eastNorth(new LatLon(b.getMinLat(), b.getMaxLon())));
     97      result.extend(latlon2eastNorth(new LatLon(b.getMaxLat(), b.getMinLon())));
     98      // and trace along the outline
     99      double dLon = (b.getMaxLon() - b.getMinLon()) / 1000;
     100      double dLat = (b.getMaxLat() - b.getMinLat()) / 1000;
     101      for (double lon=b.getMinLon(); lon<b.getMaxLon(); lon += dLon) {
     102          result.extend(latlon2eastNorth(new LatLon(b.getMinLat(), lon)));
     103          result.extend(latlon2eastNorth(new LatLon(b.getMaxLat(), lon)));
     104      }
     105      for (double lat=b.getMinLat(); lat<b.getMaxLat(); lat += dLat) {
     106          result.extend(latlon2eastNorth(new LatLon(lat, b.getMinLon())));
     107          result.extend(latlon2eastNorth(new LatLon(lat, b.getMaxLon())));
     108      }
     109      return result;
     110    }
     111
     112    @Override
    88113    public Bounds getWorldBoundsLatLon() {
    89114        org.osgeo.proj4j.proj.Projection proj = proj4jCRS.getProjection();
     
    96121
    97122        @Override
    98         public double getMetersPerUnit() {             
     123        public double getMetersPerUnit() {
    99124                return 1.0 / proj4jCRS.getProjection().getFromMetres();
    100125        }
Note: See TracChangeset for help on using the changeset viewer.