Changeset 31364 in osm for applications/editors/josm
- Timestamp:
- 2015-07-10T00:36:28+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultGeographicHandler.java
r30723 r31364 47 47 if (crsName.equalsIgnoreCase("GCS_ETRS_1989")) { 48 48 return CRS.decode("EPSG:4258"); 49 } else if (crsName.startsWith("EPSG:")) { 50 return CRS.decode(crsName); 49 51 } 50 52 return null; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r30723 r31364 43 43 public static final String GML_LINE_STRING = "LineString"; 44 44 public static final String GML_LINEAR_RING = "LinearRing"; 45 public static final String GML_POINT = "Point"; 45 46 public static final String GML_SURFACE = "Surface"; 46 47 public static final String GML_SRS_NAME = "srsName"; 47 48 public static final String GML_SRS_DIMENSION = "srsDimension"; 48 49 public static final String GML_POS_LIST = "posList"; 50 public static final String GML_COORDINATES = "coordinates"; 49 51 50 52 private final GeometryFactory geometryFactory = new GeometryFactory(); 51 53 52 54 private final GmlHandler gmlHandler; 53 55 54 56 private XMLStreamReader parser; 55 57 56 58 private int dim; 57 59 58 60 private final class CrsData { 59 61 public CoordinateReferenceSystem crs; … … 68 70 69 71 private final Map<String, CrsData> crsDataMap = new HashMap<>(); 70 72 71 73 public GmlReader(XMLStreamReader parser, GmlHandler handler) { 72 74 super(handler, NationalHandlers.DEFAULT_GML_HANDLERS); … … 84 86 } 85 87 } 86 88 87 89 private final boolean isElement(String element) { 88 90 return parser.getLocalName().matches("(gml:)?"+element); … … 105 107 return ds; 106 108 } 107 109 108 110 private void findCRS(String srs) throws NoSuchAuthorityCodeException, FactoryException { 109 111 Main.info("Finding CRS for "+srs); … … 118 120 } 119 121 } 120 122 121 123 private void parseSrs(Component parent) throws GeoCrsException, FactoryException, UserCancelException, GeoMathTransformException { 122 124 String srs = parser.getAttributeValue(null, GML_SRS_NAME); 123 dim = Integer.parseInt(parser.getAttributeValue(null, GML_SRS_DIMENSION)); 125 String sdim = parser.getAttributeValue(null, GML_SRS_DIMENSION); 126 dim = sdim != null ? Integer.parseInt(sdim) : 2; 124 127 CrsData crsData = crsDataMap.get(srs); 125 128 if (crsData == null) { … … 143 146 } 144 147 } 145 148 146 149 private void parseFeatureMember(Component parent) throws XMLStreamException, GeoCrsException, FactoryException, UserCancelException, GeoMathTransformException, MismatchedDimensionException, TransformException { 147 150 List<OsmPrimitive> list = new ArrayList<>(); … … 157 160 } else if (isElement(GML_LINEAR_RING)) { 158 161 list.add(way = createWay()); 162 } else if (isElement(GML_POINT)) { 163 parseSrs(parent); 159 164 } else if (isElement(GML_SURFACE)) { 160 165 parseSrs(parent); … … 168 173 } 169 174 } 175 } else if (isElement(GML_COORDINATES)) { 176 String[] tab = parser.getElementText().trim().split(","); 177 Point p = geometryFactory.createPoint(new Coordinate(Double.valueOf(tab[0]), Double.valueOf(tab[1]))); 178 list.add(node = createOrGetNode(p)); 170 179 } 171 180 } else if (event == XMLStreamConstants.END_ELEMENT) {
Note:
See TracChangeset
for help on using the changeset viewer.