I want to add/plot a point geometry at the boundary of all home polygons.
Conditions:
- The point should be facing the road geometry. As it will considered as the approximate entry point for that building.
- The point should not be at the corner of the polygon. It should be at the edge but not at the corners. (Not Mandatory but will be good if not at the corner)
Right now I am able to implement this by first calculating the centroid of each polygon using ST_Centroid
and then using ST_ClosestPoint
to detect the closest point of road from the centroid.
Then I draw a line starting from centroid to the closest road point using ST_MakeLine
and then detect the intersection point between the created line and building polygon using ST_Intersection
and then detect the 1st point of intersection to plot it as the required Entry Point.
Below is the graphical representation of my implemented logic where blue line is the road, and green dot is the plotted Entry Point of which I managed to avoid the corners using this logic.
Below is the result I get, which is perfectly ok in looks of what I needed
So, yes I am getting the output I needed BUT the execution time for this process is very high and I can have around 10000 polygon home structures at once. So it will be really awesome if someone can help me implement this same logic or better in a very time efficient way. Like plotting 10000 entry points within few seconds.
Can you provide the solution with some sample queries which can be directly executed?
Note: Right now I am doing this 1 polygon at a time. So I am looping through each polygons and executing this query 10000 times for 10000 polygons. Cause when I try to execute it together it just takes forever.