Changeset 30828 in osm
- Timestamp:
- 2014-11-29T20:04:57+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/OsmInspectorPlugin
- Files:
-
- 8 added
- 22 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/OsmInspectorPlugin/.classpath
r30416 r30828 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="lib" path="lib/gt-api-8.0.jar"/>5 <classpathentry kind="lib" path="lib/gt-data-8.0.jar"/>6 <classpathentry kind="lib" path="lib/gt-main-8.0.jar"/>7 <classpathentry kind="lib" path="lib/gt-opengis-8.0.jar"/>8 <classpathentry kind="lib" path="lib/gt-referencing-8.0.jar"/>9 <classpathentry kind="lib" path="lib/gt-referencing3D-8.0.jar"/>10 <classpathentry kind="lib" path="lib/gt-render-8.0.jar"/>11 <classpathentry kind="lib" path="lib/jts-1.12.jar"/>12 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> 13 <classpathentry kind="lib" path="lib/gt-wfs-8.0.jar"/>14 <classpathentry kind="lib" path="lib/gt-epsg-extension-8.0.jar"/>15 <classpathentry kind="lib" path="lib/gt-epsg-hsql-8.0.jar"/>16 <classpathentry kind="lib" path="lib/gt-metadata-8.0.jar"/>17 <classpathentry kind="lib" path="lib/gt-coverage-8.0.jar"/>18 5 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 6 <classpathentry combineaccessrules="false" kind="src" path="/JOSM-jts"/> 7 <classpathentry combineaccessrules="false" kind="src" path="/JOSM-GeoTools"/> 8 <classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/> 9 <classpathentry kind="lib" path="lib/commons-jxpath-1.3.jar"/> 10 <classpathentry kind="lib" path="lib/gt-app-schema-resolver-12.1.jar"> 11 <attributes> 12 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 13 </attributes> 14 </classpathentry> 15 <classpathentry kind="lib" path="lib/gt-cql-12.1.jar"> 16 <attributes> 17 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 18 </attributes> 19 </classpathentry> 20 <classpathentry kind="lib" path="lib/gt-render-12.1.jar"> 21 <attributes> 22 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 23 </attributes> 24 </classpathentry> 25 <classpathentry kind="lib" path="lib/gt-referencing3D-12.1.jar"> 26 <attributes> 27 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 28 </attributes> 29 </classpathentry> 30 <classpathentry kind="lib" path="lib/gt-wfs-12.1.jar"> 31 <attributes> 32 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 33 </attributes> 34 </classpathentry> 35 <classpathentry kind="lib" path="lib/gt-xml-12.1.jar"> 36 <attributes> 37 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 38 </attributes> 39 </classpathentry> 40 <classpathentry kind="lib" path="lib/gt-xsd-core-12.1.jar"> 41 <attributes> 42 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 43 </attributes> 44 </classpathentry> 45 <classpathentry kind="lib" path="lib/gt-xsd-wfs-12.1.jar"> 46 <attributes> 47 <attribute name="javadoc_location" value="http://docs.geotools.org/stable/javadocs/"/> 48 </attributes> 49 </classpathentry> 19 50 <classpathentry kind="output" path="bin"/> 20 51 </classpath> -
applications/editors/josm/plugins/OsmInspectorPlugin/build.xml
r30416 r30828 11 11 <property name="plugin.description" value="Bring in errors from Osm Inspector and display it on the current JOSM bounding box"/> 12 12 <property name="plugin.icon" value="images/osmInspector.jpg"/> 13 <property name="plugin.link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/MapDust"/> 13 <!--<property name="plugin.link" value=""/>--> 14 <property name="plugin.requires" value="jts;geotools"/> 14 15 15 16 <!-- ** include targets that all plugins have in common ** --> 16 17 <import file="../build-common.xml"/> 17 18 19 <fileset id="plugin.requires.jars" dir="${plugin.dist.dir}"> 20 <include name="jts.jar"/> 21 <include name="geotools.jar"/> 22 </fileset> 23 18 24 </project> -
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.