0

I want to write a little wms service in php, querying polygons from a mariadb database and use it with leaflet.

leaflet.js together with proj4leaflet.js calls my service with a BBOX parameter, supplying X and Y of the northwestern point and X and Y for the southeastern point. Out of these two parameters, the wms service is supposed to calculate the shape that is to be covered by this call.

Usually, if the points in the coordinate system were in perfect 90 degree angles to each other, you could easily calcualte the area with these four points:

X1,Y1  X2,Y1  X2,Y2  X1,Y2

however, this does not account for the 'skew' of CRS:25832 and I end up having annoying gaps in my grid.

My next approach, was to find the northeast point mathematically, like so (pseudo)

DIST = DISTANCE(POINT(X1,Y1), POINT(X2,Y2)) / SQRT(2);
NE = POINT(X1 + DIST, Y2 + DIST)

(and doing the same for the southwestern point).

The resulting grid has way smaller gaps, but is still far from perfect.

How would I calculate the actual corner points of the diamond(?) shape of a map tile?

Ideally, this could be done entierly in sql, using virtual columns, but I guess I could live with a php solution.

Edit:

here are some picutes of my actual data, to illustrate my problem. Squares 1,2,3 and 4 should line up perfectly, but don't.

enter image description here

On closer inspection, you see, that SE of 1 matches up with NW of 4 (pink), because these points get indicated by leaflet.

enter image description here

Points SW of 2 (purple) and NE of 3 (blue) should also be on the exact same position, but aren't.

15
  • some sample data and input and expected and actual results would go a long way toward making your question easier to follow Commented Aug 8, 2024 at 16:11
  • @ysth I added some screenshots to illustrate my problem. Hope they help Commented Aug 9, 2024 at 6:27
  • Why is this tagged with PHP and MariaDB? Commented Aug 9, 2024 at 6:30
  • @DarkBee Because these environments could be used to implement a solution to my problem. A solution using postgis, for example, would be no use to me. Feel free to edit the tags, if you don't think that this is how tags are supposed to be used. Commented Aug 9, 2024 at 6:35
  • .. Ok - And what have you tried yourself? Where are you stuck? SO is not a code-writing service Commented Aug 9, 2024 at 6:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.