int flowAreaIndex = model.getFlowAreaIndex();
int nominalPressureLossIndex = model.getNominalPressureLossIndex();
int addressIndex = model.getAddressIndex();
+ int regionIndex = model.getRegionIndex();
int mappingColumn = model.getComponentMappingIndex();
int idColumn = model.getIdIndex();
writeValue(graph, row, flowAreaIndex, vertex, DN.Vertex_HasFlowArea);
writeValue(graph, row, nominalPressureLossIndex, vertex, DN.Vertex_HasNominalPressureLoss);
writeStringValue(graph, row, addressIndex, vertex, DN.Vertex_HasAddress);
+ writeStringValue(graph, row, regionIndex, vertex, DN.HasRegion);
} catch (DatabaseException | MismatchedDimensionException | TransformException e) {
throw new RuntimeException(e);
}
Path csvFile = model.getSource();
char delim = model.getDelimiter();
+ Set<String> writtenIds = new HashSet<>();
int startXCoordColumnIndex = model.getStartXCoordIndex();
int startYCoordColumnIndex = model.getStartYCoordIndex();
int kSupplyIndex = model.getkSupplyIndex();
int lengthIndex = model.getLengthIndex();
int detailedGeometryIndex = model.getDetailedGeometryIndex();
+ int regionIndex = model.getRegionIndex();
int mappingColumn = model.getComponentMappingIndex();
int idColumn = model.getIdIndex();
DistrictImportUtils.consumeCSV(csvFile, delim, true, row -> {
try {
- String mappingValue = row.get(mappingColumn);
-
- String startXCoords = row.get(startXCoordColumnIndex);
- String startYCoords = row.get(startYCoordColumnIndex);
- String startZCoords = row.get(startZValueColumnIndex);
- String endXCoords = row.get(endXCoordColumnIndex);
- String endYCoords = row.get(endYCoordColumnIndex);
- String endZCoords = row.get(endZValueColumnIndex);
-
- double startXCoord = Double.parseDouble(startXCoords); // make negative
- double startYCoord = Double.parseDouble(startYCoords);
- double startZCoord = Double.parseDouble(startZCoords);
- double endXCoord = Double.parseDouble(endXCoords); // make negative
- double endYCoord = Double.parseDouble(endYCoords);
- double endZCoord = Double.parseDouble(endZCoords);
-
- double[] startCoords;
- double[] endCoords;
- if (actualDoTransform) {
- DirectPosition2D startTargetPos = new DirectPosition2D();
- DirectPosition2D startSourcePos = new DirectPosition2D(startXCoord, startYCoord);
- DirectPosition startRes = actualTransform.transform(startSourcePos, startTargetPos);
- startCoords = startRes.getCoordinate();
+ String idValue = row.get(idColumn);
+ if (!writtenIds.contains(idValue)) {
+ writtenIds.add(idValue);
+ String mappingValue = row.get(mappingColumn);
- DirectPosition2D endTargetPos = new DirectPosition2D();
- DirectPosition2D endSourcePos = new DirectPosition2D(endXCoord, endYCoord);
- DirectPosition endRes = actualTransform.transform(endSourcePos, endTargetPos);
- endCoords = endRes.getCoordinate();
- } else {
- startCoords = new double[] { startXCoord , startYCoord };
- endCoords = new double[] { endXCoord , endYCoord };
- }
-
- // Switch to (longitude, latitude)
- flipAxes(startCoords);
- flipAxes(endCoords);
-
- Optional<Resource> oedge = DNEdgeBuilder.create(graph, vv, model.getParentDiagram(), model.getComponentMappings().get(mappingValue), startCoords, startZCoord, endCoords, endZCoord, new double[0], padding, true);
- if (oedge.isPresent()) {
- Resource edge = oedge.get();
- writeStringValue(graph, row, idColumn, edge, DN.HasId);
+ String startXCoords = row.get(startXCoordColumnIndex);
+ String startYCoords = row.get(startYCoordColumnIndex);
+ String startZCoords = row.get(startZValueColumnIndex);
+ String endXCoords = row.get(endXCoordColumnIndex);
+ String endYCoords = row.get(endYCoordColumnIndex);
+ String endZCoords = row.get(endZValueColumnIndex);
+
+ double startXCoord = Double.parseDouble(startXCoords); // make negative
+ double startYCoord = Double.parseDouble(startYCoords);
+ double startZCoord = Double.parseDouble(startZCoords);
+
+ double endXCoord = Double.parseDouble(endXCoords); // make negative
+ double endYCoord = Double.parseDouble(endYCoords);
+ double endZCoord = Double.parseDouble(endZCoords);
+
+ double[] startCoords;
+ double[] endCoords;
+ if (actualDoTransform) {
+ DirectPosition2D startTargetPos = new DirectPosition2D();
+ DirectPosition2D startSourcePos = new DirectPosition2D(startXCoord, startYCoord);
+ DirectPosition startRes = actualTransform.transform(startSourcePos, startTargetPos);
+ startCoords = startRes.getCoordinate();
+
+ DirectPosition2D endTargetPos = new DirectPosition2D();
+ DirectPosition2D endSourcePos = new DirectPosition2D(endXCoord, endYCoord);
+ DirectPosition endRes = actualTransform.transform(endSourcePos, endTargetPos);
+ endCoords = endRes.getCoordinate();
+ } else {
+ startCoords = new double[] { startXCoord , startYCoord };
+ endCoords = new double[] { endXCoord , endYCoord };
+ }
+
+ // Switch to (longitude, latitude)
+ flipAxes(startCoords);
+ flipAxes(endCoords);
- writeValue(graph, row, diameterColumnIndex, edge, DN.Edge_HasDiameter);
- writeValue(graph, row, outerDiameterColumnIndex, edge, DN.Edge_HasOuterDiameter);
- writeValue(graph, row, nominalMassFlowIndex, edge, DN.Edge_HasNominalMassFlow);
- writeValue(graph, row, tGroundIndex, edge, DN.Edge_HasTGround);
- writeValue(graph, row, kReturnIndex, edge, DN.Edge_HasKReturn);
- 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);
+ Optional<Resource> oedge = DNEdgeBuilder.create(graph, vv, model.getParentDiagram(), model.getComponentMappings().get(mappingValue), startCoords, startZCoord, endCoords, endZCoord, new double[0], padding, true);
+ if (oedge.isPresent()) {
+ Resource edge = oedge.get();
+
+ writeStringValue(graph, row, idColumn, edge, DN.HasId);
+
+ writeValue(graph, row, diameterColumnIndex, edge, DN.Edge_HasDiameter);
+ writeValue(graph, row, outerDiameterColumnIndex, edge, DN.Edge_HasOuterDiameter);
+ writeValue(graph, row, nominalMassFlowIndex, edge, DN.Edge_HasNominalMassFlow);
+ writeValue(graph, row, tGroundIndex, edge, DN.Edge_HasTGround);
+ writeValue(graph, row, kReturnIndex, edge, DN.Edge_HasKReturn);
+ writeValue(graph, row, kSupplyIndex, edge, DN.Edge_HasKSupply);
+ writeValue(graph, row, edgeFlowAreaIndex, edge, DN.Edge_HasFlowArea);
+ writeValue(graph, row, lengthIndex, edge, DN.Edge_HasLength);
+ writeStringValue(graph, row, regionIndex, edge, DN.HasRegion);
+ writeDoubleArrayFromString(graph, row, detailedGeometryIndex, edge, DN.Edge_HasGeometry, actualTransform);
+ }
}
-
return true;
} catch (DatabaseException | MismatchedDimensionException | TransformException e) {
throw new RuntimeException(e);
public final Resource Diagram_splitToMultipleEnabled_Inverse;
public final Resource Diagram_trackChangesEnabled;
public final Resource Diagram_trackChangesEnabled_Inverse;
- public final Resource DistrictNetworkHoverInfoStyle;
public final Resource DistrictNetworkStaticInfoStyle;
public final Resource DistrictNodeGroup;
public final Resource DistrictNodeGroup_hasComponentTypeName;
public final Resource HasInLayerTag_Inverse;
public final Resource HasMapping;
public final Resource HasMapping_Inverse;
+ public final Resource HasRegion;
+ public final Resource HasRegion_Inverse;
public final Resource HasSRID;
public final Resource HasSRID_Inverse;
public final Resource HasSRTEXT;
public final Resource Mapping_InputTerminal_Inverse;
public final Resource Mapping_OutputTerminal;
public final Resource Mapping_OutputTerminal_Inverse;
+ public final Resource Mapping_Region;
+ public final Resource Mapping_Region_Inverse;
public final Resource Mapping_Terminal;
public final Resource Mapping_TerminalPair;
public final Resource Mapping_Terminals;
public static final String Diagram_splitToMultipleEnabled_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/splitToMultipleEnabled/Inverse";
public static final String Diagram_trackChangesEnabled = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/trackChangesEnabled";
public static final String Diagram_trackChangesEnabled_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Diagram/trackChangesEnabled/Inverse";
- public static final String DistrictNetworkHoverInfoStyle = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNetworkHoverInfoStyle";
public static final String DistrictNetworkStaticInfoStyle = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNetworkStaticInfoStyle";
public static final String DistrictNodeGroup = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup";
public static final String DistrictNodeGroup_hasComponentTypeName = "http://www.simantics.org/DistrictNetwork-1.0/DistrictNodeGroup/hasComponentTypeName";
public static final String HasInLayerTag_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasInLayerTag/Inverse";
public static final String HasMapping = "http://www.simantics.org/DistrictNetwork-1.0/HasMapping";
public static final String HasMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasMapping/Inverse";
+ public static final String HasRegion = "http://www.simantics.org/DistrictNetwork-1.0/HasRegion";
+ public static final String HasRegion_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasRegion/Inverse";
public static final String HasSRID = "http://www.simantics.org/DistrictNetwork-1.0/HasSRID";
public static final String HasSRID_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSRID/Inverse";
public static final String HasSRTEXT = "http://www.simantics.org/DistrictNetwork-1.0/HasSRTEXT";
public static final String Mapping_InputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal/Inverse";
public static final String Mapping_OutputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal";
public static final String Mapping_OutputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal/Inverse";
+ public static final String Mapping_Region = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Region";
+ public static final String Mapping_Region_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Region/Inverse";
public static final String Mapping_Terminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminal";
public static final String Mapping_TerminalPair = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/TerminalPair";
public static final String Mapping_Terminals = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminals";
Diagram_splitToMultipleEnabled_Inverse = getResourceOrNull(graph, URIs.Diagram_splitToMultipleEnabled_Inverse);
Diagram_trackChangesEnabled = getResourceOrNull(graph, URIs.Diagram_trackChangesEnabled);
Diagram_trackChangesEnabled_Inverse = getResourceOrNull(graph, URIs.Diagram_trackChangesEnabled_Inverse);
- DistrictNetworkHoverInfoStyle = getResourceOrNull(graph, URIs.DistrictNetworkHoverInfoStyle);
DistrictNetworkStaticInfoStyle = getResourceOrNull(graph, URIs.DistrictNetworkStaticInfoStyle);
DistrictNodeGroup = getResourceOrNull(graph, URIs.DistrictNodeGroup);
DistrictNodeGroup_hasComponentTypeName = getResourceOrNull(graph, URIs.DistrictNodeGroup_hasComponentTypeName);
HasInLayerTag_Inverse = getResourceOrNull(graph, URIs.HasInLayerTag_Inverse);
HasMapping = getResourceOrNull(graph, URIs.HasMapping);
HasMapping_Inverse = getResourceOrNull(graph, URIs.HasMapping_Inverse);
+ HasRegion = getResourceOrNull(graph, URIs.HasRegion);
+ HasRegion_Inverse = getResourceOrNull(graph, URIs.HasRegion_Inverse);
HasSRID = getResourceOrNull(graph, URIs.HasSRID);
HasSRID_Inverse = getResourceOrNull(graph, URIs.HasSRID_Inverse);
HasSRTEXT = getResourceOrNull(graph, URIs.HasSRTEXT);
Mapping_InputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_InputTerminal_Inverse);
Mapping_OutputTerminal = getResourceOrNull(graph, URIs.Mapping_OutputTerminal);
Mapping_OutputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_OutputTerminal_Inverse);
+ Mapping_Region = getResourceOrNull(graph, URIs.Mapping_Region);
+ Mapping_Region_Inverse = getResourceOrNull(graph, URIs.Mapping_Region_Inverse);
Mapping_Terminal = getResourceOrNull(graph, URIs.Mapping_Terminal);
Mapping_TerminalPair = getResourceOrNull(graph, URIs.Mapping_TerminalPair);
Mapping_Terminals = getResourceOrNull(graph, URIs.Mapping_Terminals);