From: Reino Ruusu Date: Mon, 18 Feb 2019 11:10:43 +0000 (+0200) Subject: Flipped coordinate axes for network diagrams in import wizard. X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=a5b9e41a321cfb5a2c57a07d865ace767f9023cd;p=simantics%2Fdistrict.git Flipped coordinate axes for network diagrams in import wizard. gitlab #3 Change-Id: I36b5f67821079d91f7f75d3dc9bda79d83149c8e --- 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 {