Changeset 31364 in osm for applications/editors/josm


Ignore:
Timestamp:
2015-07-10T00:36:28+02:00 (9 years ago)
Author:
donvip
Message:

[josm_opendata] see #josm11624 - better GML support

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  
    4747        if (crsName.equalsIgnoreCase("GCS_ETRS_1989")) {
    4848            return CRS.decode("EPSG:4258");
     49        } else if (crsName.startsWith("EPSG:")) {
     50            return CRS.decode(crsName);
    4951        }
    5052        return null;
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java

    r30723 r31364  
    4343    public static final String GML_LINE_STRING = "LineString";
    4444    public static final String GML_LINEAR_RING = "LinearRing";
     45    public static final String GML_POINT = "Point";
    4546    public static final String GML_SURFACE = "Surface";
    4647    public static final String GML_SRS_NAME = "srsName";
    4748    public static final String GML_SRS_DIMENSION = "srsDimension";
    4849    public static final String GML_POS_LIST = "posList";
     50    public static final String GML_COORDINATES = "coordinates";
    4951
    5052    private final GeometryFactory geometryFactory = new GeometryFactory();
    51    
     53
    5254    private final GmlHandler gmlHandler;
    53    
     55
    5456    private XMLStreamReader parser;
    55    
     57
    5658    private int dim;
    57    
     59
    5860    private final class CrsData {
    5961        public CoordinateReferenceSystem crs;
     
    6870
    6971    private final Map<String, CrsData> crsDataMap = new HashMap<>();
    70    
     72
    7173    public GmlReader(XMLStreamReader parser, GmlHandler handler) {
    7274        super(handler, NationalHandlers.DEFAULT_GML_HANDLERS);
     
    8486        }
    8587    }
    86    
     88
    8789    private final boolean isElement(String element) {
    8890        return parser.getLocalName().matches("(gml:)?"+element);
     
    105107        return ds;
    106108    }
    107    
     109
    108110    private void findCRS(String srs) throws NoSuchAuthorityCodeException, FactoryException {
    109111        Main.info("Finding CRS for "+srs);
     
    118120        }
    119121    }
    120    
     122
    121123    private void parseSrs(Component parent) throws GeoCrsException, FactoryException, UserCancelException, GeoMathTransformException {
    122124        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;
    124127        CrsData crsData = crsDataMap.get(srs);
    125128        if (crsData == null) {
     
    143146        }
    144147    }
    145    
     148
    146149    private void parseFeatureMember(Component parent) throws XMLStreamException, GeoCrsException, FactoryException, UserCancelException, GeoMathTransformException, MismatchedDimensionException, TransformException {
    147150        List<OsmPrimitive> list = new ArrayList<>();
     
    157160                } else if (isElement(GML_LINEAR_RING)) {
    158161                    list.add(way = createWay());
     162                } else if (isElement(GML_POINT)) {
     163                    parseSrs(parent);
    159164                } else if (isElement(GML_SURFACE)) {
    160165                    parseSrs(parent);
     
    168173                        }
    169174                    }
     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));
    170179                }
    171180            } else if (event == XMLStreamConstants.END_ELEMENT) {
Note: See TracChangeset for help on using the changeset viewer.