Changeset 30828 in osm for applications/editors/josm/plugins/OsmInspectorPlugin/src
- Timestamp:
- 2014-11-29T20:04:57+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/OSMIFeatureTracker.java
r30737 r30828 6 6 import org.geotools.data.memory.MemoryFeatureCollection; 7 7 import org.geotools.feature.FeatureCollection; 8 import org.geotools.feature.FeatureIterator; 8 9 import org.opengis.feature.simple.SimpleFeature; 9 10 import org.opengis.feature.simple.SimpleFeatureType; … … 34 35 } 35 36 36 features.addAll(featuresIn); 37 try (FeatureIterator<SimpleFeature> it = featuresIn.features()) { 38 while (it.hasNext()) { 39 features.add(it.next()); 40 } 41 } 37 42 } 38 43 39 44 public boolean mergeFeatures( 40 45 FeatureCollection<SimpleFeatureType, SimpleFeature> newFeatures) { 41 for (Iterator<SimpleFeature> it = newFeatures.iterator(); it.hasNext();) { 42 SimpleFeature element = (SimpleFeature) it.next(); 43 try { 44 Long ID = (Long.parseLong((String) element 45 .getAttribute("problem_id"))); 46 47 if (!hashFeatures.containsKey(ID)) { 48 hashFeatures.put(ID, element); 49 features.add(element); 50 } 51 } catch (NumberFormatException e) { 52 continue; 53 } 54 } 46 try (FeatureIterator<SimpleFeature> it = newFeatures.features()) { 47 while (it.hasNext()) { 48 SimpleFeature element = (SimpleFeature) it.next(); 49 try { 50 Long ID = (Long.parseLong((String) element 51 .getAttribute("problem_id"))); 52 53 if (!hashFeatures.containsKey(ID)) { 54 hashFeatures.put(ID, element); 55 features.add(element); 56 } 57 } catch (NumberFormatException e) { 58 continue; 59 } 60 } 61 } 55 62 56 63 return true; -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/OsmInspectorLayer.java
r30815 r30828 25 25 import org.geotools.feature.FeatureCollection; 26 26 import org.geotools.feature.FeatureIterator; 27 import org.geotools.filter.Filter;28 27 import org.geotools.geometry.jts.ReferencedEnvelope; 29 import org.geotools.map. DefaultMapContext;30 import org.geotools.map.MapConte xt;28 import org.geotools.map.FeatureLayer; 29 import org.geotools.map.MapContent; 31 30 import org.geotools.referencing.CRS; 32 31 import org.geotools.renderer.lite.StreamingRenderer; … … 46 45 import org.opengis.filter.FilterFactory2; 47 46 import org.opengis.filter.identity.FeatureId; 47 import org.opengis.filter.spatial.Intersects; 48 48 import org.opengis.referencing.FactoryException; 49 49 import org.opengis.referencing.NoSuchAuthorityCodeException; … … 73 73 74 74 private SimpleFeatureSource featureSource; 75 private MapConte xt context;75 private MapContent content; 76 76 private boolean bIsChanged; 77 77 … … 355 355 CRS.decode(Main.getProjection().toCode()); 356 356 crsOSMI = CRS.decode("EPSG:4326"); 357 conte xt = new DefaultMapContext(crsOSMI);357 content = new MapContent(crsOSMI); 358 358 359 359 selectGeomType.add(GeomType.POINT); … … 371 371 OSMIFeatureTracker tracker = new OSMIFeatureTracker(features); 372 372 arrFeatures.add(tracker); 373 FeatureIterator<SimpleFeature> it = tracker.getFeatures() 374 .features(); 373 FeatureIterator<SimpleFeature> it = tracker.getFeatures().features(); 375 374 376 375 while (it.hasNext()) { … … 379 378 } 380 379 381 conte xt.addLayer(tracker.getFeatures(), style);380 content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); 382 381 } 383 382 384 383 osmiIndex = new BugIndex(osmiBugInfo); 385 conte xt.setTitle("Osm Inspector Errors");386 renderer.set Context(context);384 content.setTitle("Osm Inspector Errors"); 385 renderer.setMapContent(content); 387 386 bIsChanged = true; 388 387 … … 407 406 String typeNames[] = wfsClient.getTypeNames(); 408 407 409 conte xt.clearLayerList();408 content.layers().clear(); 410 409 selectGeomType.clear(); 411 410 selectGeomType.add(GeomType.POINT); … … 438 437 439 438 Style style = createDefaultStyle(idx, selectedFeatures); 440 conte xt.addLayer(tracker.getFeatures(), style);439 content.addLayer(new FeatureLayer(tracker.getFeatures(), style)); 441 440 } 442 441 … … 596 595 ReferencedEnvelope mapArea = new ReferencedEnvelope(envelope, crsOSMI); 597 596 598 Filter filter = (Filter)ff.intersects(ff.property("msGeometry"),597 Intersects filter = ff.intersects(ff.property("msGeometry"), 599 598 ff.literal(mapArea)); 600 599 // 601 600 // Select features in all layers 602 601 // 603 conte xt.clearLayerList();602 content.layers().clear(); 604 603 605 604 // Iterate through features and build a list that intersects the above … … 615 614 try { 616 615 selectedFeatures = tempfs.getFeatures(filter); 617 618 FeatureIterator<SimpleFeature> iter = selectedFeatures.features(); 619 Set<FeatureId> IDs = new HashSet<>(); 620 621 Main.info("Selected features " + selectedFeatures.size()); 622 623 while (iter.hasNext()) { 624 SimpleFeature feature = iter.next(); 625 IDs.add(feature.getIdentifier()); 616 Set<FeatureId> IDs = new HashSet<>(); 617 618 try (FeatureIterator<SimpleFeature> iter = selectedFeatures.features()) { 619 620 Main.info("Selected features " + selectedFeatures.size()); 621 622 while (iter.hasNext()) { 623 SimpleFeature feature = iter.next(); 624 IDs.add(feature.getIdentifier()); 625 } 626 626 } 627 628 iter.close();629 627 630 628 geometryType = selectGeomType.get(idx + layerOffset); 631 629 Style style = createDefaultStyle(idx + layerOffset, IDs); 632 conte xt.addLayer(features, style);630 content.addLayer(new FeatureLayer(features, style)); 633 631 } catch (IOException e) { 634 // TODO Auto-generated catch block 635 e.printStackTrace(); 632 Main.error(e); 636 633 } 637 634 } -
applications/editors/josm/plugins/OsmInspectorPlugin/src/org/openstreetmap/josm/plugins/osminspector/gui/OsmInspectorDialog.java
r30815 r30828 44 44 45 45 public void updateNextPrevAction(OsmInspectorLayer l) { 46 this.actNext. layer = l;47 this.actPrev. layer = l;46 this.actNext.inspectlayer = l; 47 this.actPrev.inspectlayer = l; 48 48 } 49 49 … … 164 164 ListSelectionListener { 165 165 166 private OsmInspectorLayer layer;166 private OsmInspectorLayer inspectlayer; 167 167 168 168 public OsmInspectorNextAction(Layer inspector) { 169 169 super("next"); 170 layer = (OsmInspectorLayer) inspector;170 inspectlayer = (OsmInspectorLayer) inspector; 171 171 } 172 172 173 173 @Override 174 174 public void actionPerformed(ActionEvent e) { 175 layer.getOsmiIndex().next();176 BugInfo next = layer.getOsmiIndex().getItemPointedByNext();175 inspectlayer.getOsmiIndex().next(); 176 BugInfo next = inspectlayer.getOsmiIndex().getItemPointedByNext(); 177 177 Geometry geom = next.getGeom(); 178 178 Point centroid = geom.getCentroid(); 179 179 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 180 180 Main.map.mapView.zoomTo(center); 181 layer.selectFeatures(center);181 inspectlayer.selectFeatures(center); 182 182 bugInfoDialog.setBugDescription(next); 183 183 updateSelection(next); … … 199 199 ListSelectionListener { 200 200 201 private OsmInspectorLayer layer;201 private OsmInspectorLayer inspectlayer; 202 202 203 203 public OsmInspectorPrevAction(Layer inspector) { 204 204 super("prev"); 205 layer = (OsmInspectorLayer) inspector;205 inspectlayer = (OsmInspectorLayer) inspector; 206 206 } 207 207 208 208 @Override 209 209 public void actionPerformed(ActionEvent e) { 210 layer.getOsmiIndex().prev();211 BugInfo prev = layer.getOsmiIndex().getItemPointedByPrev();210 inspectlayer.getOsmiIndex().prev(); 211 BugInfo prev = inspectlayer.getOsmiIndex().getItemPointedByPrev(); 212 212 Geometry geom = prev.getGeom(); 213 213 Point centroid = geom.getCentroid(); 214 214 LatLon center = new LatLon(centroid.getY(), centroid.getX()); 215 215 Main.map.mapView.zoomTo(center); 216 layer.selectFeatures(center);216 inspectlayer.selectFeatures(center); 217 217 bugInfoDialog.setBugDescription(prev); 218 218 updateSelection(prev);
Note:
See TracChangeset
for help on using the changeset viewer.