tile38
tile38 copied to clipboard
circle object?
Is there some way to create an object that is a point with a radius? It seems like a useful primitive but I don't see it supported by geojson or otherwise..
I would like to do something like SET stores store1 CIRCLE 33.5123 -112.2693 245.0
I agree that it would be useful to have a simple RADIUS/CIRCLE type, something I've thought about in the past. The only problem is that there's no Circle type in the GeoJSON spec, and Tile38 requires that all objects must be represented as valid a GeoJSON payload when requested by the user.
It's possible to generate a circle in GeoJSON by using a LineString and drawing the circle as a series of segments. The downside to this approach is that there's a higher serialization cost and the LineString may not perfectly represent the original point+radius.
Could tile38 be made to understand a geojson point with the radius specified as a property?
Do you mean something like this?
{
"type":"Feature",
"geometry":{"type":"Point","coordinates":[-112.2693,33.5123]},
"properties": {
"type": "Circle",
"radius": 245,
"radius_units": "m"
}
}
This would be valid GeoJSON, but a GeoJSON library that is not aware of the extended properties will just think it's a generic point.
Another option would be to adopt the proposed Circle type:
{"type": "Circle", "coordinates": [-112.2693,33.5123], "radius": 0.245}
This looks much better and in the future it may be adopted in the spec. My biggest concern is that strict GeoJSON libraries won't know how to generate or parse it.
That being said, it would be pretty nice to find a solution that works.
Yeah I meant your first example.
I'm inclined to say using point and properties is the better way to go. It doesn't look like the circle proposal is going anywhere..
How much work would it be to add support to tile38?
I'm inclined to say using point and properties is the better way to go. It doesn't look like the circle proposal is going anywhere..
I agree that using a Point+properties is the way to go.
How much work would it be to add support to tile38?
Hard to say right now. I'll need to investigate it further, but unfortunately available time for new features is limited due to the heavy workload for v2.0. I'll add this to the list of potential future enhancements. If we find that it's simple enough to implement we'll bump up the priority.
I have code that will convert a point like
{
"geometry": {
"coordinates": [ xxxx, yyyy ],
"type": "Point"
},
"properties": {
"id": "212c7a42-3b27-4b01-adca-b8891380d6a1",
"radius": 50
},
"type": "Feature"
}
into a polygon with n points. This isn't ideal as it's going to be much less efficient than a point in circle test..
Can you provide guidance on how I would add support for the point and radius property to tile38?
ping?
@predmond.
Sorry for the delayed response.
I still think that is something that would be great for Tile38.
Perhaps the best approach is to use this format:
{
"type":"Feature",
"geometry":{"type":"Point","coordinates":[-112.2693,33.5123]},
"properties": {
"type": "Circle",
"radius": 245,
"radius_units": "m"
}
}
Then when the Tile38 geojson library parses the json, it coule recognize that the object is a "Feature", the geometry is a "Point" and there properties.type is "Circle". And it will generate a new Circle type.
I would explore this path as solution.
This would indeed be a great feature to add. We've been trying to use fences by creating a collection of fences and then setting up hooks of the form:
SETHOOK hook:<fence id> <url> WITHIN devices FENCE DETECT enter,exit GET fence <fence id>
however this format doesn't appear to work for circular fences of the form point + radius in GeoJSON. For those we would need to instead create them as a special case
SETHOOK hook:<fence id> <url> WITHIN devices FENCE DETECT enter,exit CIRCLE point, radius
which leads to the chance the fence geometry and the hook geometry could get out of sync. Maybe there is a better solution.
Hi tidwall how can I use "INTERSECTS" in this manner of Circle ?
Has there been any development to add circle as a geometry natively? I think this is a very useful feature to add because many geofences are circlar and use cases exist where people need to identify when a location update resides inside a circle. @tidwall
I think I had a PR laying around and eventually closed it. If I remember correctly it was because you can pass every shape as an object and otherwise you'd end up with method for each shape people want to add.
@iwpnd @tidwall , I understand your concern, but circles have a very useful purpose. You may currently view them as just another shape, but they can be beneficial in situations where someone needs to query for members and check if their location is within 100 meters ( , 200 meters , 250 meters or x meters) of an object or point. You may argue that we can use the "NEARBY" query, but this method has predefined ranges and limits us from customizing the distances from a particular point.
Moreover, while we can define most shapes with polygons, we do not have native support for defining circular shapes. The only option is to define a polygon with 8 or more sides, which may not make sense in some scenarios.
Personally, I think defining circles would be a significant advantage when creating geofences. With location updates, we can easily determine if the location is within range of a particular point defined as a circle. Hooks can be limiting, which is why I suggest considering the use of circles.
Here is the PR by @iwpnd that includes the circle type. https://github.com/tidwall/tile38/pull/649 I would consider taking another look.
@tidwall any plans on integrating circle objects anytime soon?
@Mukund2900 I don't have plans atm. The process of including the circle type will require additional review of the PR, integration tests, and deployment. This is mostly a time constraint concern on my side.
Sure @tidwall , actually I wanted to use that feature. I guess for now I will have to go with NEARBY approach or figure out other ways to accomplish my use case. Thank-you.
Use WITHIN to see if x is in y meters of any object.
@iwpnd using the NEARBY command in Tile38 is not suitable for my use case. In my scenario, I need to receive notifications whenever a location update falls within a specific range from a given point. The range will vary over time (so will need to expire that key) and differ for each point.
Using the NEARBY command will not be an optimal choice since it requires fetching all the data from the location, let's say 10 km worth of data, and then checking each point's distance to see which ones are within the specified range. With over 5,000 updates per second, this method is not viable due to the amount of data processing involved.
Still thanks for your suggestion.
You might want to look up the WITHIN command. And I sense you're using chatGPT for your answers.
@iwpnd Yeah WITHIN command is what I want but for circle geofences (which is not supported). And yes I am using ChatGpt so I can explain myself better because English is not my native language.
Cool use case for it 👍