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

top left corner values incorrect #1229

Open
skydish opened this issue Mar 28, 2024 · 0 comments
Open

top left corner values incorrect #1229

skydish opened this issue Mar 28, 2024 · 0 comments

Comments

@skydish
Copy link

skydish commented Mar 28, 2024

When I use the GeoWebCache WMTS GetCapabilities request, I noticed that the order of the top left corner values of my layer's matrix set is incorrect. Instead of being Y, X, it is given as X, Y. Is there a way to modify this order and set it as Y, X?The incorrect order of the values has caused me to be unable to calculate the position of the first tile map correctly in the following code that uses GeoTools.

the code get wroing is in this line cause (lon - tileMatrixMinX) / tileSpanX + epsilon) and(lon - tileMatrixMinX) / tileSpanX + epsilon) It is a negative number.
long xTile = (long)((int)Math.floor((lon - tileMatrixMinX) / tileSpanX + epsilon));
long yTile = (long)((int)Math.floor((tileMatrixMaxY - lat) / tileSpanY + epsilon));


public TileIdentifier identifyTileAtCoordinate(double lon, double lat, ZoomLevel zoomLevel) {
WMTSZoomLevel zl = (WMTSZoomLevel)zoomLevel;
TileMatrix tileMatrix = (TileMatrix)this.getMatrixSet().getMatrices().get(zl.getZoomLevel());
double pixelSpan = WMTSTileFactory.getPixelSpan(tileMatrix);
double tileSpanY = (double)tileMatrix.getTileHeight() * pixelSpan;
double tileSpanX = (double)tileMatrix.getTileWidth() * pixelSpan;
double tileMatrixMinX;
double tileMatrixMaxY;
if (tileMatrix.getCrs().getCoordinateSystem().getAxis(0).getDirection().equals(AxisDirection.EAST)) {
tileMatrixMinX = tileMatrix.getTopLeft().getX();
tileMatrixMaxY = tileMatrix.getTopLeft().getY();
} else {
tileMatrixMaxY = tileMatrix.getTopLeft().getX();
tileMatrixMinX = tileMatrix.getTopLeft().getY();
}

    double epsilon = 1.0E-6;
    long xTile = (long)((int)Math.floor((lon - tileMatrixMinX) / tileSpanX + epsilon));
    long yTile = (long)((int)Math.floor((tileMatrixMaxY - lat) / tileSpanY + epsilon));
    xTile = Math.max(0L, xTile);
    yTile = Math.max(0L, yTile);
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine("identifyTile: (lon,lat)=(" + lon + "," + lat + ")  (col,row)=" + xTile + ", " + yTile + " zoom:" + zoomLevel.getZoomLevel());
    }

    return new WMTSTileIdentifier((int)xTile, (int)yTile, zoomLevel, this.getName());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant