Skip to content

Commit

Permalink
Revert some unecessary srid changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Jan 23, 2024
1 parent 1959ec3 commit e231544
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@



import static org.apache.baremaps.utils.GeometryUtils.GEOMETRY_FACTORY_WGS84;

import java.util.List;
import java.util.function.Consumer;
import org.apache.baremaps.database.collection.DataMap;
Expand Down Expand Up @@ -72,13 +70,6 @@ public void accept(Entity entity) {
} else if (entity instanceof Relation relation && isMultiPolygon(relation)) {
relationMultiPolygonBuilder.accept(relation);
}

// TODO: Find out why a few geometries get a srid of 0
if (entity instanceof Element element
&& element.getGeometry() != null
&& element.getGeometry().getSRID() != GEOMETRY_FACTORY_WGS84.getSRID()) {
element.getGeometry().setSRID(GEOMETRY_FACTORY_WGS84.getSRID());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void accept(Entity entity) {
&& entity instanceof Element element
&& element.getGeometry() != null) {
var geometry = projectionTransformer.transform(element.getGeometry());
geometry.setSRID(targetSrid);
element.setGeometry(geometry);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected CoordinateSequence transformCoordinates(
return new CoordinateArraySequence(coordinateArray);
}

@Override
protected Geometry transformPoint(Point geom, Geometry parent) {
try {
var geometry = super.transformPoint(geom, parent);
Expand All @@ -100,6 +101,7 @@ protected Geometry transformPoint(Point geom, Geometry parent) {
}
}

@Override
protected Geometry transformMultiPoint(MultiPoint geom, Geometry parent) {
try {
var geometry = super.transformMultiPoint(geom, parent);
Expand All @@ -110,38 +112,41 @@ protected Geometry transformMultiPoint(MultiPoint geom, Geometry parent) {
return geometry;
} catch (Exception e) {
logger.error("MultiPoint cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createMultiPoint();
geometry.setSRID(targetSrid);
return geometry;
}
}

@Override
protected Geometry transformLinearRing(LinearRing geom, Geometry parent) {
try {
var geometry = super.transformLinearRing(geom, parent);
geometry.setSRID(targetSrid);
return geometry;
} catch (Exception e) {
logger.error("LinearRing cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createLinearRing();
geometry.setSRID(targetSrid);
return geometry;
}
}

@Override
protected Geometry transformLineString(LineString geom, Geometry parent) {
try {
var geometry = super.transformLineString(geom, parent);
geometry.setSRID(targetSrid);
return geometry;
} catch (Exception e) {
logger.error("LineString cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createLineString();
geometry.setSRID(targetSrid);
return geometry;
}
}

@Override
protected Geometry transformMultiLineString(MultiLineString geom, Geometry parent) {
try {
var geometry = super.transformMultiLineString(geom, parent);
Expand All @@ -152,25 +157,27 @@ protected Geometry transformMultiLineString(MultiLineString geom, Geometry paren
return geometry;
} catch (Exception e) {
logger.error("MultiLineString cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createMultiLineString();
geometry.setSRID(targetSrid);
return geometry;
}
}

@Override
protected Geometry transformPolygon(Polygon geom, Geometry parent) {
try {
var geometry = super.transformPolygon(geom, parent);
geometry.setSRID(targetSrid);
return geometry;
} catch (Exception e) {
logger.error("Polygon cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createPolygon();
geometry.setSRID(targetSrid);
return geometry;
}
}

@Override
protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent) {
try {
var geometry = super.transformMultiPolygon(geom, parent);
Expand All @@ -181,23 +188,23 @@ protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent) {
return geometry;
} catch (Exception e) {
logger.error("MultiPolygon cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createMultiPolygon();
geometry.setSRID(targetSrid);
return geometry;
}
}

@Override
protected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent) {
try {
var geometry = super.transformGeometryCollection(geom, parent);
geometry.setSRID(targetSrid);
return geometry;
} catch (Exception e) {
logger.error("GeometryCollection cannot be reprojected", e);
var geometry = parent.getFactory().createPoint();
var geometry = parent.getFactory().createGeometryCollection();
geometry.setSRID(targetSrid);
return geometry;
}
}

}

0 comments on commit e231544

Please sign in to comment.