tSql plot point in centre of grid cells - sql

Original question below:
'What is the best way to achieve the below in sql:
Take an area such as Chicago Illinois, place a grid over it of cells 50m x 50m and place a point in the centre of each grid cell. The coordinates of each point will be used to look at a table of lat/longs and calculate which of these points are within 200m of each point from the grid.'
To provide more detail to the above to make things a bit clearer. The greater aim is to:
Query a table of lat/longs in sql (2012) to find the greatest number of points in a 200m radius. I believe that using the Geography capabilities in sql I can accomplish much of this. To be able to sample the table of points I wanted to create a grid (say of New York - 50m x 50m cells) and move a circle (200m radius) into the center of each square grid cell and then use the buffer function to find what was within the circle. However, I've been searching online and I haven't been able to find a way to create the grid and the central lat/longs.
I am aware of the haversine equation and have used it before (the inverse of this I suppose is what I'm looking for). I would just appreciate some guidance to make sure I don't go down the wrong avenue for too long.

When you are talking about UI You can't handle it in sql.
SQl is a relational database management system, or RDBMS, that supports a wide variety of transaction processing, business intelligence and analytics applications in corporate IT environments. but UI use In information technology, the user interface (UI) is everything designed into an information device with which a person may interact. This can include display screens, keyboards, a mouse and the appearance of a desktop. It is also the way through which a user interacts with an application or a website. The growing dependence of many companies on web applications and mobile applications has led many companies to place increased priority on UI in an effort to improve the user's overall experience .WHEN YOU ARE TALKING A BOUT DESIGN YOU HAVE TO USE UI NOT SQL.
this link can help you to find your solution.

Related

Looking for a way to capture elevation and location data from a device to create a topographical map or model

I'm in the process of buying a 7.5 acre plot of land in a wooded, hilly area. I would estimate that the elevation varies about 50 feet from the bottom of the creek to the top of the hill. I would like to find a good method for measuring the topography of the land so I can create a 3D model. It would be tremendously useful to be able to try out different land development ideas and to simulate locations for future buildings.
My low-tech version of doing this would be to set up a laser level and go around taking elevation measurements in a 3' or so grid pattern. As I thought about that, I realized that smartphones and similar devices have quite a few sensors built in that might make this a lot easier.
I learned about software that will use a drone to capture data and images to automatically generate a topo map and 3D model. Drone Deploy is one such tool. I do have a DJI Phantom 4, but I don't know if it's feasible to fly such an intricate path among trees to scan the entire property. I wonder if there's another way to use this amazing modern hardware (phone or drone) to make my task easy.
I would appreciate hearing any thoughts and ideas about this!
The thing with dronedeploy is that you fly above the trees usually 30meters is ok. In a cross pattern.
Why do you want to fly between the trees? You have to explain that first.

How to store large ever-changing tile map in a database efficiently

I'm currently developing a game as a personal project! One of the main aspects of the game is the map - it will be a multiplayer game whereby players can capture different areas of a map by building things.
The map will be very big! Around 1000x1000 (so 1M tiles). The game will also have a fair amount of players on the map at the same time (100-1000), who will be constantly capturing new areas and stealing areas from other players, as such the tile database will be constantly changing in real time.
My question is - does anyone have any recommendations on how to go about this? My initial ideas were:
Have a MongoDB database with a collection of tiles.
Pros: Can query for certain areas of the map so that the client only has to download a portion of the map every time
Cons: Collection will be very large (several GB) (each tile would need to have X, Y coordinates, a resource level, an owner, and whether another player is contesting the tile)
Have an SQL database
Pros: Will be lighter in size, probably quicker to query.
Cons: Might not be able to be written to and edited easily in real time.
Any thoughts / direction would be greatly appreciated!
Thank you!
If I understand the question, It sound like spatial indexing is the way to go. with a good spatial index it will be trivial to locate the player and determine which parts of the map are nearby. I've only ever used it for geo-data, but with the correct polygons it should be usable in your scenario as well.
Microsoft does a much better explanation than I can give in a stackoverflow answer, and similar functionality exists in MongoDB. Hope that helps.
A million tiles is not necessarily a large quantity of objects for a database to manage. Like other types of addressable assets (e.g. airline seats, hotel rooms, concert tickets), each map tile will have a primary key identifier that is indexed for fast retrieval and precise, targeted updates.
Depending on the rules regarding movement across tiles and how much volatile information is involved in rendering a tile, you may want to devise a prefetching scheme that anticipates which tiles a player might need next and downloads them in advance to minimize delays.
In order for your application to accommodate hundreds or thousands of users who are simultaneously viewing, modifying, and taking ownership of specific records without suffering from lock timeouts and deadlocks, your database model and query workload will need to be designed for concurrency. SQL-based databases allow you to use normalization techniques to arrive at a data model which not only accurately represents the data you're managing, but also eliminates the risk of duplicate records, double-booking, lost updates, and other anomalies. If your data model is adequately normalized and your application is making proper use of atomic transactions (units of work), the A.C.I.D. properties of SQL-based databases offer powerful, built-in protection for your data with minimal application coding.

How to calculate ETA without a map

Need a little help from someone who knows a little about logistics;
I am currently working with an application known as Framework. The application is not really something that I am familiar with, but regardless I can figure out how it works. One of the tabs running in the application is for expected orders (shipping trucks). Within that, I am able to see where an outbound truck's current location is, as well as it's destination. I am trying to add functionality to the application that would allow me to see an estimated time of arrival to its current destination + the drive back to my location. This seems simple enough, but I'm trying to figure out the best way that I could calculate this. I looked into The Google Distance Matrix API, but I have no need to display a map on the application, all I want is the ETA. I am pretty inexperienced with this kind of thing, so I was hoping someone could point me in the right direction.
Thanks guys.
This may not be the best forum for this question...
It looks like Google Distance Matrix requires you to display the map. An alternative is the open source OSRM project. Natively it's a C++ engine for routing, which outputs directions and the total route information so the any map display is up to you.
There is a demo and HTTP API hosted on the project site but you will need to check if it's suitable for your usage level.
Just an idea, but depending on the size of your delivery area, and how accurate you want the estimated time, you may be able to keep it all in a database.
Let's assume your delivery area is 10 miles x 10 miles.
So that's 100 square miles. We'll use each square mile as a point.
Do a one time calculation of how long it will take to get from each
point to the rest. You can
use the Google Distance Matrix API for this since you're only doing
this once.
This will give you 10,000 records that has every point to point time.
So, if your truck is in point 25, and has to get to point 64, you do a lookup and see that it should take about 10 minutes. plus the drive from point 64 back to the warehouse (point 10) is 8 minutes. Then you'll know the truck should be back in about 18 minutes.
It's not super accurate, but it might be close enough for your needs. I would be curious if you do implement this method.
Btw, if your delivery area is 100 miles x 100 miles, then that would be 100,000,000 location points if each point is 1 square mile. If that's too much, then if you increase your point size to 2 miles x 2 miles (4 square miles), then that's about 6,000,000 records.

Location data storage (points, grouping by distance etc) - Best Practices and Recommended Solutions

I have come across a problem that I 've never solved before but I find it frequently implemented in various apps so I would like to ask if there is a common way to solve it. I have a set of analytics data each representing some logging action (i.e. info, warn etc). Each of this items has a location and a type (i.e. action). There can be millions of these items per area (depending on the area size or map zoom).
I am looking for the best way to store this set of data in my database. I am very comfortable with SQL Server but dont mind what db I have to use as long as it can handle the scalability requirements. If Amazon WS offers such a product or some other cloud solution then even better cause thats how we are planning to host this app. Google maps will be used to visualize the data.
Some requirements:
Be able to plot all data for a given map rectangle (a common google
map interface with markers representing the logging actions)
Be able to zoom in/zoom out and get relevant data for the new map rectangle
Be able to "group" markers in one bigger marker if data are very close. For instance, if point A is 1 km away from point B and I am seeing a map of 10 km radius then I should see two independent points, A and B. But if I zoom out to 500 km radius then point A and B are too close to each other so I would like to group them in one marker. Hopefully that's possible.
If SQL Server is not a good solution then a free, very cheap or cloud-based storage solution should be recommended (no I cant afford an Oracle).
All the queries above should be able to come back within milliseconds or somehow to be cached. Queries will be of the kind: Get me all analytics data for the given map window with zoom of the given rectangle latitude/longitude.
Thanks,
Yannis
If I undertsood correctly, there are 2 sides to your question:
1- A Database System, that supports storage and lookup of spatial data. Many of the free/open source RDBMS have spatial extensions: MySQL and Postgres (PostGIS) in particular. Spatial data are stored like any other data with the addition of spatial geometry attribute, which describes the shape of your data instance (point, rectangle, polygon, ellipse, ...). You can query spatial data entities, with spatial filters. And of course, spatial queries support joints and unions and almost all kind of SQL constructs.
2- A client/server api that would support rendering of spatial data (with the usual functions such as zoom in, zoom out, pan, etc.), caching and drill-down. As far as I know, there isn't one api that support all these features together, out the box. But there are some interesting apis that you might want to investigate.
Hope this helps.

Algorithm for reducing GPS track data to discard redundant data?

We're building a GIS interface to display GPS track data, e.g. imagine the raw data set from a guy wandering around a neighborhood on a bike for an hour. A set of data like this with perhaps a new point recorded every 5 seconds, will be large and displaying it in a browser or a handheld device will be challenging. Also, displaying every single point is usually not necessary since a user can't visually resolve that much data anyway.
So for performance reasons we are looking for algorithms that are good at 'reducing' data like this so that the number of points being displayed is reduced significantly but in such a way that it doesn't risk data mis-interpretation. For example, if our fictional bike rider stops for a drink, we certainly don't want to draw 100 lat/lon points in a cluster around the 7-Eleven.
We are aware of clustering, which is good for when looking at a bunch of disconnected points, however what we need is something that applies to tracks as described above. Thanks.
A more scientific and perhaps more math heavy solution is to use the Ramer-Douglas-Peucker algorithm to generalize your path. I used it when I studied for my Master of Surveying so it's a proven thing. :-)
Giving your path and the minimum angle you can tolerate in your path, it simplifies the path by reducing the number of points.
Typically the best way of doing that is:
Determine the minimum number of screen pixels you want between GPS points displayed.
Determine the distance represented by each pixel in the current zoom level.
Multiply answer 1 by answer 2 to get the minimum distance between coordinates you want to display.
starting from the first coordinate in the journey path, read each next coordinate until you've reached the required minimum distance from the current point. Repeat.