From a5b9e41a321cfb5a2c57a07d865ace767f9023cd Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 18 Feb 2019 13:10:43 +0200 Subject: [PATCH] Flipped coordinate axes for network diagrams in import wizard. gitlab #3 Change-Id: I36b5f67821079d91f7f75d3dc9bda79d83149c8e --- .../district/imports/ui/CSVImportWizard.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizard.java b/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizard.java index 490c9505..54a578dd 100644 --- a/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizard.java +++ b/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizard.java @@ -176,6 +176,10 @@ public class CSVImportWizard extends Wizard implements IImportWizard { } else { coords = new double[] { xCoord, yCoord }; } + + // Switch to (longitude, latitude) + flipAxes(coords); + Resource vertex = DistrictNetworkUtil.createVertex(graph, model.getParentDiagram(), coords, model.getComponentMappings().get(mappingValue)); writeStringValue(graph, row, idColumn, vertex, DN.HasId); @@ -230,7 +234,11 @@ public class CSVImportWizard extends Wizard implements IImportWizard { startCoords = new double[] { startXCoord , startYCoord }; endCoords = new double[] { endXCoord , endYCoord }; } - + + // Switch to (longitude, latitude) + flipAxes(startCoords); + flipAxes(endCoords); + Resource edge = DNEdgeBuilder.create(graph, vv, model.getParentDiagram(), model.getComponentMappings().get(mappingValue), startCoords, endCoords, padding, true); writeStringValue(graph, row, idColumn, edge, DN.HasId); @@ -267,9 +275,15 @@ public class CSVImportWizard extends Wizard implements IImportWizard { return false; } } - + + private static void flipAxes(double[] coords) { + double tmp = coords[0]; + coords[0] = coords[1]; + coords[1] = tmp; + } + private static void writeValue(WriteGraph graph, CSVRecord row, int index, Resource subject, Resource relation) throws DatabaseException { - if (index != -1) { + if (index != -1) { String stringValue = row.get(index); if (!stringValue.isEmpty()) { try { -- 2.47.1