Ignore:
Timestamp:
2015-05-28T21:06:56+02:00 (9 years ago)
Author:
malcolmh
Message:

clip to map bounds

Location:
applications/editors/josm/plugins/seachartedit/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachartedit/src/panels/PanelS57.java

    r31060 r31156  
    6565                        tin.close();
    6666                }
    67                 map = new S57map();
     67                map = new S57map(true);
    6868                MapBounds bounds = S57dec.decodeFile(in, map);
    6969
  • applications/editors/josm/plugins/seachartedit/src/panels/ShowFrame.java

    r31060 r31156  
    4141                        id = osm.getUniqueId();
    4242                        feature = map.index.get(id);
    43                         showMap = new S57map();
     43                        showMap = new S57map(true);
    4444                        showMap.nodes = map.nodes;
    4545                        showMap.edges = map.edges;
  • applications/editors/josm/plugins/seachartedit/src/scedit/SCeditAction.java

    r31060 r31156  
    2323import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;
    2424import org.openstreetmap.josm.gui.layer.*;
     25import org.openstreetmap.josm.data.Bounds;
    2526import org.openstreetmap.josm.data.SelectionChangedListener;
     27import org.openstreetmap.josm.data.coor.LatLon;
    2628import org.openstreetmap.josm.data.osm.*;
    2729import org.openstreetmap.josm.data.osm.event.*;
     
    198200
    199201        void makeMap() {
    200                 map = new S57map();
     202                map = new S57map(true);
    201203                if (data != null) {
     204                        double minlat = 90;
     205                        double maxlat = -90;
     206                        double minlon = 180;
     207                        double maxlon = -180;
     208                        for (Bounds bounds : data.getDataSourceBounds()) {
     209                                if (bounds.getMinLat() < minlat) {
     210                                        minlat = bounds.getMinLat();
     211                                }
     212                                if (bounds.getMaxLat() > maxlat) {
     213                                        maxlat = bounds.getMaxLat();
     214                                }
     215                                if (bounds.getMinLon() < minlon) {
     216                                        minlon = bounds.getMinLon();
     217                                }
     218                                if (bounds.getMaxLon() > maxlon) {
     219                                        maxlon = bounds.getMaxLon();
     220                                }
     221                        }
     222                        map.addNode(1, maxlat, minlon);
     223                        map.addNode(2, minlat, minlon);
     224                        map.addNode(3, minlat, maxlon);
     225                        map.addNode(4, maxlat, maxlon);
     226                        map.bounds.minlat = Math.toRadians(minlat);
     227                        map.bounds.maxlat = Math.toRadians(maxlat);
     228                        map.bounds.minlon = Math.toRadians(minlon);
     229                        map.bounds.maxlon = Math.toRadians(maxlon);
    202230                        for (Node node : data.getNodes()) {
    203                                 map.addNode(node.getUniqueId(), node.getCoor().lat(), node.getCoor().lon());
    204                                 for (Entry<String, String> entry : node.getKeys().entrySet()) {
    205                                         map.addTag(entry.getKey(), entry.getValue());
    206                                 }
    207                                 map.tagsDone(node.getUniqueId());
     231                                LatLon coor = node.getCoor();
     232                                if (coor != null) {
     233                                        map.addNode(node.getUniqueId(), coor.lat(), coor.lon());
     234                                        for (Entry<String, String> entry : node.getKeys().entrySet()) {
     235                                                map.addTag(entry.getKey(), entry.getValue());
     236                                        }
     237                                        map.tagsDone(node.getUniqueId());
     238                                }
    208239                        }
    209240                        for (Way way : data.getWays()) {
     
    232263                                }
    233264                        }
     265                        map.mapDone();
    234266                }
    235267        }
Note: See TracChangeset for help on using the changeset viewer.