@Override public Object parse(ElementInstance instance, Node node, Object value) throws Exception { List children = node.getChildren("curveMember"); List<LineString> components = new ArrayList<>(); for (Iterator it = children.iterator(); it.hasNext(); ) { Node child = (Node) it.next(); if (child.getValue() instanceof LineString) { LineString ls = (LineString) child.getValue(); components.add(ls); } } if (components.isEmpty()) { return gFactory.createLineString(new Coordinate[0]); } else { CoordinateSequence cs = components.get(0).getCoordinateSequence(); CurvedGeometryFactory factory = GML3ParsingUtils.getCurvedGeometryFactory(arcParameters, gFactory, cs); return factory.createCurvedGeometry(components); } }
GML3ParsingUtils.getCurvedGeometryFactory( arcParameters, gf,
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { LineString[] segments = (LineString[]) node.getChildValue("segments"); if (segments.length == 0) { return null; } else if (segments.length == 1) { return segments[0]; } else { LineString curved = null; for (LineString ls : segments) { if (ls instanceof CurvedGeometry<?>) { curved = ls; } } CurvedGeometryFactory factory = GML3ParsingUtils.getCurvedGeometryFactory( arcParameters, gf, curved != null ? curved.getCoordinateSequence() : null); return factory.createCurvedGeometry(Arrays.asList(segments)); } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ @Override public Object parse(ElementInstance instance, Node node, Object value) throws Exception { LineString arcLineString = GML3ParsingUtils.lineString(node, gFactory, csFactory); CoordinateSequence cs = arcLineString.getCoordinateSequence(); if (cs.size() < 3) { // maybe log this instead and return null throw new RuntimeException( "Number of coordinates in an arc string must be at least 3, " + cs.size() + " were specified: " + arcLineString); } CurvedGeometryFactory factory = GML3ParsingUtils.getCurvedGeometryFactory(arcParameters, gFactory, cs); return factory.createCurvedGeometry(cs); } }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { LineString arcLineString = GML3ParsingUtils.lineString(node, gFactory, csFactory); CoordinateSequence cs = arcLineString.getCoordinateSequence(); if (cs.size() < 3) { // maybe log this instead and return null throw new RuntimeException( "Number of coordinates in an arc string must be at least 3, " + cs.size() + " were specified: " + arcLineString); } CurvedGeometryFactory factory = GML3ParsingUtils.getCurvedGeometryFactory(arcParameters, gFactory, cs); return factory.createCurvedGeometry(cs); }