Skip to content

Commit

Permalink
bugfix vectordb wms axis orientation; vectordb sort attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
swoellauer committed Mar 15, 2024
1 parent c1daf14 commit c4a94bf
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/src/layouts/MainLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ export default defineComponent({
this.sessionCnt++;
image.getImage().src = srcUrl;
},
params: {},
params: { VERSION: "1.1.1" },
}),
});
this.refreshVectordbLayerParameters(layerEntry);
Expand Down
14 changes: 9 additions & 5 deletions src/server/api/vectordbs/ConverterRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public void filter(CoordinateSequence seq, int i) {
}
};

public static ImageBufferARGB renderProportionalFullMaxSize(DataSource datasource, Object sync, int maxWidth, int maxHeight, String labelField, Style style, Transformer layerRenderTransformer, boolean swapCoordinates) {
public static ImageBufferARGB renderProportionalFullMaxSize(DataSource datasource, VectorDB sync, int maxWidth, int maxHeight, String labelField, Style style, Transformer layerRenderTransformer, boolean swapCoordinates) {
Rect2d renderRect = VectorDB.getExtent(VectorDB.getPoints(datasource, sync));
return renderProportionalFullMaxSize(datasource, sync, renderRect, maxWidth, maxHeight, labelField, style, layerRenderTransformer, swapCoordinates);
}

public static ImageBufferARGB renderProportionalFullMaxSize(DataSource datasource, Object sync, Rect2d renderRect, int maxWidth, int maxHeight, String labelField, Style style, Transformer layerRenderTransformer, boolean swapCoordinates) {
public static ImageBufferARGB renderProportionalFullMaxSize(DataSource datasource, VectorDB sync, Rect2d renderRect, int maxWidth, int maxHeight, String labelField, Style style, Transformer layerRenderTransformer, boolean swapCoordinates) {
double xlen = renderRect.width();
double ylen = renderRect.height();

Expand All @@ -63,7 +63,7 @@ public static ImageBufferARGB renderProportionalFullMaxSize(DataSource datasourc
return render(datasource, sync, renderRect, width, height, labelField, style, layerRenderTransformer, swapCoordinates);
}

public static ImageBufferARGB render(DataSource datasource, Object sync, Rect2d renderRect, int width, int height, String labelField, Style style, Transformer layerRenderTransformer, boolean swapCoordinates) {
public static ImageBufferARGB render(DataSource datasource, VectorDB sync, Rect2d renderRect, int width, int height, String labelField, Style style, Transformer layerRenderTransformer, boolean swapCoordinates) {
ImageBufferARGB image = new ImageBufferARGB(width, height);
Graphics2D gc = image.bufferedImage.createGraphics();
gc.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Expand All @@ -86,6 +86,7 @@ public static ImageBufferARGB render(DataSource datasource, Object sync, Rect2d
layer.SetSpatialFilter(null); // clear filter
layer.ResetReading(); // reset iterator
Feature feature = layer.GetNextFeature();
int missingGeometries = 0;
while(feature != null) {
try {
Geometry geometry = feature.GetGeometryRef();
Expand All @@ -110,13 +111,16 @@ public static ImageBufferARGB render(DataSource datasource, Object sync, Rect2d
styleJtsGeometryRasterizer.acceptGeometry(style, jtsGeometry, label);
}
} else {
Logger.warn("missing geometry");
missingGeometries++;
}
} catch(Exception e) {
Logger.warn(e);
Logger.warn(e.getMessage());
}
feature = layer.GetNextFeature();
}
if(missingGeometries > 0) {
Logger.info(missingGeometries + " missing geometries of feature from vectordb " + sync.getName());
}
}
}
styleJtsGeometryRasterizer.drawLabels(style);
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/vectordbs/VectordbHandler_raster_png.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void handleGET(VectorDB vectordb, String target, Request request, Respons
if(style == null) {
style = Renderer.STYLE_DEFAULT;
}
ImageBufferARGB image = ConverterRenderer.renderProportionalFullMaxSize(datasource, this, maxWidth, maxHeight, null, style, null, false);
ImageBufferARGB image = ConverterRenderer.renderProportionalFullMaxSize(datasource, vectordb, maxWidth, maxHeight, null, style, null, false);

/*double[] extent = VectorDB.getExtent(VectorDB.getPoints(datasource));
Logger.info(Arrays.toString(extent));
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/vectordbs/VectordbHandler_root.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void handleGET(VectorDB vectordb, String target, Request request, Respons
json.key("proj4");
json.value(details.proj4);
json.key("attributes");
json.value(details.attributes);
json.value(details.attributes.stream().sorted(String.CASE_INSENSITIVE_ORDER).toArray());
json.endObject();

if(Web.getFlagBoolean(request, "extent")) {
Expand Down
37 changes: 33 additions & 4 deletions src/server/api/vectordbs/VectordbHandler_wms.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ public void handle_GetMap(VectorDB vectordb, Request request, Response response,
try {
int width = Web.getInt(request, "WIDTH");
int height = Web.getInt(request, "HEIGHT");
String crs = Web.getString(request, "CRS");
String crs = Web.getString(request, "CRS", null);
if(crs == null) {
crs = Web.getString(request, "SRS", null);
}
if(crs == null) {
throw new RuntimeException("parameter not found: CRS or SRS");
}
util.GeoUtil.Transformer layerWmsTransformer = null;

SpatialReference layerSr = vectordb.getSpatialReference();
Expand All @@ -111,7 +117,7 @@ public void handle_GetMap(VectorDB vectordb, Request request, Response response,
if(wmsSr != null) {
if(wmsSr.IsSame(layerSr) == 0) {
layerWmsTransformer = new GeoUtil.Transformer(layerSr, wmsSr);
//Logger.info("transform " + layerWmsTransformer.toString());
Logger.info("transform " + layerWmsTransformer.toString());
}
}
}
Expand All @@ -135,7 +141,25 @@ public void handle_GetMap(VectorDB vectordb, Request request, Response response,
style = Renderer.STYLE_DEFAULT;
}
boolean swapCoordinates = layerWmsTransformer != null && layerWmsTransformer.dstFirstAxis == 1;
image = ConverterRenderer.render(datasource, vectordb, wmsRect, width, height, labelField, style, layerWmsTransformer, swapCoordinates);
if(layerWmsTransformer == null) {
if(layerSr != null) {
swapCoordinates = layerSr.GetAxisOrientation(null, 0) == 1;
// if(GeoUtil.WGS84_SPATIAL_REFERENCE.IsSame(layerSr) != 0) { // workaround for swapped axis but not in GetAxisOrientation for EPSG:4326
// swapCoordinates = true;
// } else {
// swapCoordinates = layerSr.GetAxisOrientation(null, 0) == 1;
// }
}
}
Logger.info("layerSr.GetAxisOrientation(null, 0) " + layerSr.GetAxisOrientation(null, 0) + " " + swapCoordinates);
image = ConverterRenderer.render(datasource, vectordb, wmsRect, width, height, labelField, style, layerWmsTransformer, swapCoordinates);
//image = ConverterRenderer.render(datasource, vectordb, wmsRect, width, height, labelField, style, layerWmsTransformer, false);

printCRSinfo(3044);
printCRSinfo(3857);
printCRSinfo(4326);
printCRSinfo(32632);
printCRSinfo(32633);
}
} finally {
VectorDB.closeDataSource(datasource);
Expand Down Expand Up @@ -172,6 +196,11 @@ public void handle_GetMap(VectorDB vectordb, Request request, Response response,
Logger.warn(e);
}
}

private static void printCRSinfo(int epsg) {
SpatialReference sr = GeoUtil.getSpatialReferenceFromEPSG(epsg);
Logger.info(epsg + " AxisOrientation " + sr.GetAxisOrientation(null, 0));
}

public void handle_GetCapabilities(VectorDB vectordb, Request request, Response response, UserIdentity userIdentity) throws IOException {
String requestUrl = request.getRequestURL().toString();
Expand Down Expand Up @@ -274,7 +303,7 @@ private void addRootLayer(VectorDB vectordb, Element eCapability, String name, S

addStyle(vectordb, eRootLayer, requestUrl);
}

private static int getHeight() {
return 45;
}
Expand Down
4 changes: 2 additions & 2 deletions src/util/GeoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public Transformer(SpatialReference srcSr, SpatialReference dstSr) {
this.srcSr = srcSr;
this.dstSr = dstSr;
this.coordinateTransformation = CoordinateTransformation.CreateCoordinateTransformation(srcSr, dstSr);
this.srcFirstAxis = srcSr.GetAxisOrientation(null, 0);
this.dstFirstAxis = dstSr.GetAxisOrientation(null, 0);
this.srcFirstAxis = GeoUtil.WGS84_SPATIAL_REFERENCE.IsSame(srcSr) != 0 ? 1 : srcSr.GetAxisOrientation(null, 0); // workaround for swapped axis but not in GetAxisOrientation for EPSG:4326
this.dstFirstAxis = GeoUtil.WGS84_SPATIAL_REFERENCE.IsSame(dstSr) != 0 ? 1 : dstSr.GetAxisOrientation(null, 0); // workaround for swapped axis but not in GetAxisOrientation for EPSG:4326
}

public void transformWithAxisOrderCorrection(double[][] points) {
Expand Down

0 comments on commit c4a94bf

Please sign in to comment.