int kReturnIndex = model.getkReturnIndex();
int kSupplyIndex = model.getkSupplyIndex();
int lengthIndex = model.getLengthIndex();
+ int detailedGeometryIndex = model.getDetailedGeometryIndex();
int mappingColumn = model.getComponentMappingIndex();
int idColumn = model.getIdIndex();
writeValue(graph, row, kSupplyIndex, edge, DN.Edge_HasKSupply);
writeValue(graph, row, edgeFlowAreaIndex, edge, DN.Edge_HasFlowArea);
writeValue(graph, row, lengthIndex, edge, DN.Edge_HasLength);
+ writeDoubleArrayFromString(graph, row, detailedGeometryIndex, edge, DN.Edge_HasGeometry, actualTransform);
}
} catch (MismatchedDimensionException | TransformException | DatabaseException e) {
throw new DatabaseException(e);
}
}
}
+
+ private static void writeDoubleArrayFromString(WriteGraph graph, CSVRecord row, int index, Resource subject, Resource relation, MathTransform actualTransform) throws DatabaseException, MismatchedDimensionException, TransformException {
+ if (index != -1) {
+ String stringValue = row.get(index);
+ if (!stringValue.isEmpty()) {
+ stringValue = stringValue.substring(1, stringValue.length() - 1);
+ String[] coordPairs = stringValue.split(";");
+ ArrayList<Double> dd = new ArrayList<>(coordPairs.length * 2);
+ for (int i = 0; i < coordPairs.length; i++) {
+ String coordPair = coordPairs[i];
+ String[] p = coordPair.split(" ");
+ double x = Double.parseDouble(p[0]);
+ double y = Double.parseDouble(p[1]);
+ if (actualTransform != null) {
+ DirectPosition2D targetPos = new DirectPosition2D();
+ DirectPosition2D sourcePos = new DirectPosition2D(y, x);
+ DirectPosition res = actualTransform.transform(sourcePos, targetPos);
+ double[] coords = res.getCoordinate();
+ x = coords[1];
+ y = coords[0];
+ }
+ dd.add(x);
+ dd.add(y);
+ }
+ double[] detailedGeometryCoords = new double[dd.size()];
+ for (int i = 0; i < dd.size(); i++) {
+ double d = dd.get(i);
+ detailedGeometryCoords[i] = d;
+ }
+ try {
+ graph.claimLiteral(subject, relation, detailedGeometryCoords, Bindings.DOUBLE_ARRAY);
+ } catch (NumberFormatException e) {
+ throw new DatabaseException(e);
+ }
+ }
+ }
+ }
}