Can any one provide mathematical technique details about turf js? - geospatial

Can you tell me how turf js perform operation?
Like, Point to Ploygon, we can use buffer for that.
var point = turf.point([-90.548630, 14.616599]);
var buffered = turf.buffer(point, 500, {units: 'miles'});
So which mathematical technique they are using for that?
As well as for Points to Envelop or Convex hull or concave.
Is there any documentation for that?

If you are curious about how does it work, you can source the code:
Here you have the git dependency.
Also, the point feature.

Related

How to add two 3D meshes to get single mesh in python

I'm playing with some mesh operations.
Suppose we have two meshes, one human head mesh and another one is human body.
we just have to add head to body so that the end result is one single complete human body
mesh.
I think it can be done using python-blender but i'm not that much expert in blender scripting.
May be another python library can be useful.
Please recommend some way out.
Tried join operation in blender. But it's working as expected because we want to add the two meshes
at specific location i.e. neck.
Boolean operation on meshes is a novelty of open3d v0.16, you could take a look at it :
[http://www.open3d.org/blog/][link]

How to create geocoding service (find polygons that intersect a given point)

SITUATION
I have a database with 2,000,000 cities. All of them have coordinates of the city center and mostly all - GeoJSON boundaries. I'm trying to implement a geocoding service that would find cities that intersect with a given point using node.js, mongodb, redis, memcached (and golang, if that is necessary, cause I'm just totally new to it )
PROBLEM
I know how to work with points (lat and lng) since both MongoDB and Redis support geoindexes but I've never seen anything about polygons.
I guess MongoDB won't really help cause of its speed (since it work on disks), but any memory database should deal with this problem. The thing is I can't even think of any way to implement it.
I'll be happy if someone point me how to make it. Thanks.
You may implement a point-in-polygon algorithm yourself. I've done something similar on https://api.3geonames.org
First do a bounding box to identify candidate polygons, then run a PIP. https://en.wikipedia.org/wiki/Point_in_polygon
geo.lua (https://github.com/RedisLabs/geo.lua) works with the requirements you have here but it's not very performant (not sure what has changed since last i checked).

What's the best way to determine if a point is within a certain distance of a GEOJSON polygon?

What's the best way to determine if a point is within a certain distance of a GEOJSON polygon? Should one use TurfJS buffer method (https://github.com/Turfjs/turf-buffer#turf-buffer)? Can one perform queries on the buffered polygon?
It's clear to me one could us the TurfJS' inside method (https://github.com/Turfjs/turf-inside) to determine whether a point is within a polygon. I'm just curious what the best approach would be for finding whether or not a point is inside of a buffered polygon.
For example:
I have a number of neighborhoods provided as a GEOJSON polygon files. I also have a set of locations/addresses for employees (already geocoded to lat/long coordinates). What would be the best way to see whether or not my employees live within 10 miles of a given neighborhood polygon?
Thanks!
Yes, you can use buffer in conjunction with inside to find points within 10 miles of something else, eg, expanding on the existing examples,
var pt = point(14.616599, -90.548630)
var unit = 'miles'
var buffered = buffer(pt, 10, unit)
var ptTest = point(-1, 52)
var bIn = inside (ptIn, buffer)
which should obviously be false.
In general, though, buffering is somewhat expensive, so you would not necessarily want to do this every time you run the query. There are a couple of things you can do to speed things up:
1). Pre-buffer your search areas
2). Use some kind of R-tree type index, which will first check bounding box intersection, and avoid lots of unecessary point in polygon operations. turfjs, which I hadn't heard of until seeing your post, uses jsts under the hood for a number of operations, including buffering. This library has an implemention of R-tree indexes that you could potentially use. Here is a fun example of this being done.
In general, in situations where you have a spatial (R-tree type) index in place, such as a spatially enabled database like Postgis on top of Postgres, you would use an operator like ST_Dwithin (geom1, geom2, distance) in a where clause to find all points within some distance of another geometry, and this would be very efficient as many candidates would be rejected for failing an initial bounding box test.
Really, it depends on the size of your data and frequency of queries. There is nothing, in principle, wrong with doing contains queries on a buffer. I hope I haven't created more questions than answers.
I'm using GeoScript to do that sort of calculations in JavaScript. It has a distance method in the geom.Geometry class which can return the minimum distance between two geometries. You could use that, or take a look at the source on GitHub to see how they do it if you want to roll your own solution.

How to know the client whether 2D or 3D inside XServer(Xorg)

In X windowing system is there a way to know that any particular client is 2D or 3D?
Any structure in XORG side with a parameter by which this decision can be made?
There is a structure _Client which contains the information about the client but I dont know if any parameter of this structure can be used to make this decision.
Please help if anyone is aware of this.
Thanks

Get the nearest node from a coordinate in openstreetmap database

I have for example a coordinate:
41,791063, 12,6923072
and I want to find the nearest node in the OSM DB
in this example the node 906459460
http://www.openstreetmap.org/api/0.6/node/906459460
then I want to konw which ways is part of
in this example
http://www.openstreetmap.org/api/0.6/way/78456451
http://www.openstreetmap.org/api/0.6/way/76966153
http://www.openstreetmap.org/api/0.6/way/76965957
How can I do using the API? thanks
I don't think this is possible using the API directly, though I might be wrong.
http://en.wikipedia.org/wiki/Nearest_neighbor_search
is a general problem in computer science and I believe there are various ways to tackle it.

Resources