open.mp forum
[Pawn] Dynamic Polygon Street Names - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Dynamic Polygon Street Names (/showthread.php?tid=1163)



Dynamic Polygon Street Names - Torque - 2020-08-21

Good evening all,

I'm currently setting up polygon areas for street names. Currently, I have it set as follows:

Code:
new area_StreetName;
new Float:Array_StreetName[] =
{
   x, y,
   x, y,
   x, y
};

I have about 20 of these so far, and to me, this seems really inefficient.

What I would like, is a float which contains the street name, and county, and then the points, like so...

Code:
new Float:StreetNames[][StreetInfo]
{ "StreetName", "TownName, CountyName", POINTS },

Code:
enum StreetInfo {
   StreetName_1[64],
   StreetName_2[64],
   Float:POINTS
};

Perhaps using an enum to store that information. But because the amount of points for a given street could be anything from 4 to 25 points, how would I go about storing this into an enum?

Thanks


RE: Dynamic Polygon Street Names - Pinch - 2020-08-22

I don't think that using dynamic areas for street names would be an good idea, take a look at this as it is already perfectly made, you can fork & edit it if you need to:

https://github.com/kristoisberg/samp-map-zones/blob/master/map-zones.inc


RE: Dynamic Polygon Street Names - Torque - 2020-08-22

That wouldn't work with street names, as roads require more than 4 points, due to their shape and length.



I'm only covering Red County, not the entire map, so hopefully the amount of dynamic areas won't impact performance or cause issues. There is a way to do this which I've figured out with the help of somebody else. But Polygon areas is a must for this to work.


RE: Dynamic Polygon Street Names - Y_Less - 2020-09-23

I don't think areas are the best way to go about this, but this is a hard algorithm problem to do efficiently. I strongly suspect that you need to do some serious computer science research I'm sure someone in acadaemia has done some work in this area to get a more efficient algorithm. The better bet is probably splitting roads up in to small straight-line segments and building up from there, but I don't know the most efficient way to organise those spatially, and I doubt anyone here does unfortunately.


RE: Dynamic Polygon Street Names - Cakey - 2020-09-26

3. ok "elitist"


RE: Dynamic Polygon Street Names - Y_Less - 2020-09-26

1) Your benchmarking is wrong.



2) You don't need the square root, you only need to compare relative distances to find the closest.


RE: Dynamic Polygon Street Names - BigETI - 2020-09-26

You can have a network, where each node represents an intersection or point on a curve. Node connections would define roads. To find out what road you are , you just find out the nearest line segment and if the perpendicular distance to that road is bigger than road thickness, then you are not on a road.


RE: Dynamic Polygon Street Names - Freaksken - 2020-09-28

(2020-09-23, 11:53 AM)Y_Less Wrote: but I don't know the most efficient way to organise those spatially, and I doubt anyone here does unfortunately.

Quadtrees?


RE: Dynamic Polygon Street Names - Y_Less - 2020-09-28

Probably, yes. I was thinking of some custom data structure for specifically this data, but you're right. And they nest well, so any straight line segment that doesn't fit entirely within a block can just be put in the next square up. Plus you only need to search the closest blocks. I should have thought of that - it's how y_objects worked!


RE: Dynamic Polygon Street Names - Torque - 2020-09-29

Thanks for the help, very interesting. I have however decided to move the server to Las Venturas, and for this reason, there's no way in hell I'll be doing street names here. Red County isn't too bad as the towns are small, but there's so many streets in the city it would take way to long to do something like this via script on it's own.



It would definitely be an interesting feature to have as perhaps an include or something, giving that element of GTA IV.