I am creating a mapping application which users can interactively draw a polygon on a Google Map.
I need to send this polygon data back to a Sql Server and determine which records to return based on their LatLng positions in the database being within the polygon.
Does anyone know how to do this or a routine that is available.
Thanks in advance
If you have a geography column associated with your records, you can use that to query for items within a polygon. Link to get you started. Here's an example:
--What Items are within the Bermuda Triangle?
---Note that Well-Known Text representation of a polygon is composed of points defined by Longitude then Latitude.
---Note that the points are defined in a counter-clockwise order so that the polygon is the interior of the triangle.
DECLARE #BermudaTriangle geography = geography::STPolyFromText
('POLYGON((
-80.190262 25.774252,
-66.118292 18.466465,
-64.75737 32.321384,
-80.190262 25.774252
))', 4326)
SELECT ItemID, ReportedGPSPoint.Lat, ReportedGPSPoint.Long
FROM Items
WHERE ReportedGPSPoint.STIntersects(#BermudaTriangle) = 1
Related
I have two tables named polygon & paths which contains polygons data and paths(line string) respectively. I am trying to build a query in which I will pass lineString data and on the basis of that, I want to fetch all the polygons which that lineString intersects.
I am quite new to this Please suggest some approach by the help of that I can be able to achieve this.
Thank you.
You question is very general. But if you want to get the polygons that intersects with the line then the query in postgis would be something like this
SELECT p.* FROM polygon_table AS p, line_table as l
WHERE
st_intersects(p.geom, l.geom)
geom are the columns representing the geometry column, and make sure that both tables have same SRID.
I want to draw a polygon ( or even better to use already defined lat.long) in Tableau map.
is it possible?
Regards
Yes, choose the polygon mark type, put latitude and longitude on the row and column shelves and a field on the path shelf to specify point order.
Use other dimensions on additional shelves such as detail or color if you have multiple polygons to display
I am trying to do a grid based clustering, specifically where each U.S. state is a grid. What I am doing now is just setting strategy option of ClusterProvider to STRATEGY_GRID_BASED, but I don't think this is what I think it is.
I tried looking into nokia.maps.clustering.IGridOptions, but there isn't anything documentation on that.
Can someone point me in the right direction? Thanks.
A Grid-based clustering strategy just breaks the map up into squares and calculates how many markers are found in each square. What you are after is known as a Chloropleth Map. The most efficient way to do this would be to cluster server-side, return a key,value pair (i.e. state, number of markers) and just display polygons for the US States. An example of such a map can be found in the HERE Maps community examples which displays the accession dates of states to the union.
If you insist on doing everything client side then you'd have to use the following pseudo code instead:
Iterate though each marker in your list:
Check to see if it is within the hit area of an existing polygon.
If it is - increment the markers counter (an additional attribute you have added.)
If it isn't make a WKT State-level shape geocoding request, and parse the result -add a new markers counter attribute to the Polygon
repeat
You will then end up with a series of polygon objects each holding an attribute with the number of markers within found within the state.
I've a fusion table map example with 5 layers given in this link : http://jsfiddle.net/ju2Re/
I want to filter the layers such that,
first I select a layer using dropdown : Office hierarchy > Zone > Bagalkot
Now I want to select the 220 KV stations only inside that polygon using the select box.
Please anyone help. Thank you in advance.
I don't believe you can do this natively with fusion tables (at least
not right now). The only query that can be used for "point in
polygon" analysis is:
ST_INTERSECTS(,
)
.
That takes a geometry as one argument, but the only values of are:
-
-
So if you have one point, you can use it to define a small circle and
use ST_INTERSECTS with a polygon, but that won't work for multiple
points.
With the current size of your tables you can use GViz to retrieve the
data from FusionTables and analyze it in the browser.
Proof of Concept (only works for "Geographical Heirarchy"/"District")
The code adds a "Contains" method to google.maps.Polygon, then iterates through the markers, displaying them if they are contained in the "activePolygon".
Proof of Concept should handle all the cases that have data
I am trying to generate pins over the map of my database coordinates by using fusion table and I want to generate only within 1 mile area circle around the specific location. To get 1 mile area's coordinates similar to my db coordinates I've to put condition of < and > to fusion table but I don't know how to get all the coordinates within 1 mile area circle or what should be the value for condition in query. Can any one please help me to figure out, it'll really appreciable.
You haven't provided any code, so I'm not exactly sure what you want to do. But the Fusion Table ST_INTERSECTS operator should do what you want. Look for <spatial_condition>.
var where = "ST_INTERSECTS('location_col',CIRCLE(LATLNG(31.954109,-115.441528), radius_in_meters) ) )";
var qryOpts = {
query: {
select: location_col,
from: table_id,
where: where
}
};
ft_layer.setOptions(qryOpts);
I have no idea if that is possible within the Fusion Tables API but, if I were doing it, I would first calculate which points in my database were within the radius and insert only those. You can ignore the earth's curvature and just use the Pythagorean theorem with a little adjusting for your latitude.
See here: http://www.movable-type.co.uk/scripts/latlong.html