Changeset 18477 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/vector/VectorDataStore.java
r18473 r18477 17 17 import java.util.Map; 18 18 import java.util.Objects; 19 import java.util.stream.Collectors; 19 20 20 21 import org.openstreetmap.gui.jmapviewer.Tile; … … 25 26 import org.openstreetmap.josm.data.imagery.vectortile.VectorTile; 26 27 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.Feature; 28 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.GeometryTypes; 27 29 import org.openstreetmap.josm.data.imagery.vectortile.mapbox.Layer; 28 30 import org.openstreetmap.josm.data.osm.BBox; … … 294 296 final Map<ILatLon, VectorNode> nodeMap = new HashMap<>(); 295 297 for (Layer layer : tile.getLayers()) { 296 for (Feature feature : layer.getFeatures()) { 297 try { 298 addFeatureData(tile, layer, feature, nodeMap); 299 } catch (IllegalArgumentException e) { 300 Logging.error("Cannot add vector data for feature {0} of tile {1}: {2}", feature, tile, e.getMessage()); 301 Logging.error(e); 298 Map<GeometryTypes, List<Feature>> grouped = layer.getFeatures().stream().collect(Collectors.groupingBy(Feature::getGeometryType)); 299 // Unknown -> Point -> LineString -> Polygon 300 for (GeometryTypes type : GeometryTypes.values()) { 301 if (grouped.containsKey(type)) { 302 addFeatureData(tile, layer, grouped.get(type), nodeMap); 302 303 } 303 304 } … … 312 313 } 313 314 315 private <T extends Tile & VectorTile> void addFeatureData(T tile, Layer layer, Collection<Feature> features, Map<ILatLon, VectorNode> nodeMap) { 316 for (Feature feature : features) { 317 try { 318 addFeatureData(tile, layer, feature, nodeMap); 319 } catch (IllegalArgumentException e) { 320 Logging.error("Cannot add vector data for feature {0} of tile {1}: {2}", feature, tile, e.getMessage()); 321 Logging.error(e); 322 } 323 } 324 } 325 314 326 private <T extends Tile & VectorTile> void addFeatureData(T tile, Layer layer, Feature feature, Map<ILatLon, VectorNode> nodeMap) { 315 327 // This will typically be larger than primaryFeatureObjects, but this at least avoids quite a few ArrayList#grow calls 316 328 List<VectorPrimitive> featureObjects = new ArrayList<>(feature.getGeometryObject().getShapes().size()); 317 List<VectorPrimitive> primaryFeatureObjects = new ArrayList<>(feature Objects.size());329 List<VectorPrimitive> primaryFeatureObjects = new ArrayList<>(feature.getGeometryObject().getShapes().size()); 318 330 for (Shape shape : feature.getGeometryObject().getShapes()) { 319 331 primaryFeatureObjects.add(shapeToPrimaryFeatureObject(tile, layer, shape, featureObjects, nodeMap)); -
trunk/test/unit/org/openstreetmap/josm/data/vector/VectorDataSetTest.java
r17862 r18477 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.vector; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 import java.nio.file.Paths; 8 import java.util.ArrayList; 9 import java.util.Collection; 10 import java.util.Collections; 11 import java.util.HashSet; 3 12 4 13 import org.awaitility.Awaitility; … … 14 23 import org.openstreetmap.josm.gui.layer.imagery.MVTLayer; 15 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 17 import java.nio.file.Paths;18 import java.util.ArrayList;19 import java.util.Collection;20 import java.util.Collections;21 import java.util.HashSet;22 23 import static org.junit.jupiter.api.Assertions.assertEquals;24 import static org.junit.jupiter.api.Assertions.assertTrue;25 25 26 26 /** -
trunk/test/unit/org/openstreetmap/josm/data/vector/VectorNodeTest.java
r17867 r18477 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.vector; 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 import static org.junit.jupiter.api.Assertions.fail; 10 11 import java.util.ArrayList; 12 import java.util.Collections; 13 import java.util.List; 3 14 4 15 import org.junit.jupiter.api.Test; … … 15 26 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 18 import java.util.ArrayList;19 import java.util.Collections;20 import java.util.List;21 22 import static org.junit.jupiter.api.Assertions.assertEquals;23 import static org.junit.jupiter.api.Assertions.assertFalse;24 import static org.junit.jupiter.api.Assertions.assertNotNull;25 import static org.junit.jupiter.api.Assertions.assertSame;26 import static org.junit.jupiter.api.Assertions.assertTrue;27 import static org.junit.jupiter.api.Assertions.fail;28 28 29 29 /** … … 144 144 assertSame(way, node.getReferrers(true).get(0)); 145 145 // No dataset yet 146 assertTrue(node.isReferredByWays(1)); 147 VectorDataSet dataSet = new VectorDataSet(); 148 dataSet.addPrimitive(node); 149 // Way is not yet in dataset 146 150 assertFalse(node.isReferredByWays(1)); 147 VectorDataSet dataSet = new VectorDataSet();148 151 dataSet.addPrimitive(way); 149 dataSet.addPrimitive(node);150 152 assertTrue(node.isReferredByWays(1)); 151 153 assertFalse(node.isReferredByWays(2));
Note:
See TracChangeset
for help on using the changeset viewer.