Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CGMES GL import #2992

Merged
merged 11 commits into from
May 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class CgmesGLExporter {
private static final Logger LOG = LoggerFactory.getLogger(CgmesGLExporter.class);
public static final String MD_NAMESPACE = "http://iec.ch/TC57/61970-552/ModelDescription/1#";

private Network network;
private TripleStore tripleStore;
private final Network network;
private final TripleStore tripleStore;

private static final String MODEL_SCENARIO_TIME = "Model.scenarioTime";
private static final String MODEL_CREATED = "Model.created";
Expand Down Expand Up @@ -99,8 +99,8 @@ private void addModel(ExportContext context) {
private void addCoordinateSystem(ExportContext context) {
PropertyBag coordinateSystemProperties = new PropertyBag(Arrays.asList(IDENTIFIED_OBJECT_NAME, "crsUrn"), true);
coordinateSystemProperties.setClassPropertyNames(Collections.singletonList(IDENTIFIED_OBJECT_NAME));
coordinateSystemProperties.put(IDENTIFIED_OBJECT_NAME, CgmesGLUtils.COORDINATE_SYSTEM_NAME);
coordinateSystemProperties.put("crsUrn", CgmesGLUtils.COORDINATE_SYSTEM_URN);
coordinateSystemProperties.put(IDENTIFIED_OBJECT_NAME, CgmesGLUtils.COORDINATE_SYSTEM_NAME);
context.setCoordinateSystemId(tripleStore.add(context.getGlContext(), CgmesNamespace.CIM_16_NAMESPACE, "CoordinateSystem", coordinateSystemProperties));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
*/
public final class CgmesGLUtils {

public static final String COORDINATE_SYSTEM_NAME = "WGS84";
/**
* Coordinate system WGS84 (World Geodetic System 1984)
*/
public static final String COORDINATE_SYSTEM_NAME = "WGS84"; // Not required in import, but used for export
public static final String COORDINATE_SYSTEM_URN = "urn:ogc:def:crs:EPSG::4326";

private CgmesGLUtils() {
}

public static boolean checkCoordinateSystem(String crsName, String crsUrn) {
return COORDINATE_SYSTEM_NAME.equals(crsName) && COORDINATE_SYSTEM_URN.equals(crsUrn);
public static boolean checkCoordinateSystem(String crsUrn) {
return COORDINATE_SYSTEM_URN.equals(crsUrn);
}

public static String contextNameFor(CgmesSubset subset, TripleStore tripleStore, String modelId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void importPosition() {
private void importPosition(PropertyBag linePositionData, Map<Line, SortedMap<Integer, Coordinate>> lineCoordinates,
Map<DanglingLine, SortedMap<Integer, Coordinate>> danglingLineCoordinates) {
Objects.requireNonNull(linePositionData);
if (!CgmesGLUtils.checkCoordinateSystem(linePositionData.getId("crsName"), linePositionData.getId("crsUrn"))) {
if (!CgmesGLUtils.checkCoordinateSystem(linePositionData.getId("crsUrn"))) {
throw new PowsyblException("Unsupported coodinates system: " + linePositionData.getId("crsName"));
}
String lineId = linePositionData.getId("powerSystemResource");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SubstationPositionImporter(Network network) {

public void importPosition(PropertyBag substationPositionData) {
Objects.requireNonNull(substationPositionData);
if (!CgmesGLUtils.checkCoordinateSystem(substationPositionData.getId("crsName"), substationPositionData.getId("crsUrn"))) {
if (!CgmesGLUtils.checkCoordinateSystem(substationPositionData.getId("crsUrn"))) {
throw new PowsyblException("Unsupported coodinates system: " + substationPositionData.getId("crsName"));
}
String substationId = substationPositionData.getId("powerSystemResource");
Expand Down
2 changes: 0 additions & 2 deletions cgmes/cgmes-gl/src/main/resources/CGMES-GL.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ SELECT ?powerSystemResource ?name ?crsName ?crsUrn ?x ?y ?seq
cim:IdentifiedObject.name ?name .
?coordinateSystem
a cim:CoordinateSystem ;
cim:IdentifiedObject.name ?crsName ;
cim:CoordinateSystem.crsUrn ?crsUrn .
?positionPoint
a cim:PositionPoint ;
Expand All @@ -38,7 +37,6 @@ SELECT ?powerSystemResource ?name ?crsName ?crsUrn ?x ?y ?seq
cim:IdentifiedObject.name ?name .
?coordinateSystem
a cim:CoordinateSystem ;
cim:IdentifiedObject.name ?crsName ;
cim:CoordinateSystem.crsUrn ?crsUrn .
?positionPoint
a cim:PositionPoint ;
Expand Down