I am hoping you guys can help me out. I play a Facebook game called Dragons of Atlantis. It is a Real-Time Strategy game with a large world map. The world map is a 750x750 grid. I'd like to know the details of each coordinate of that grid, as unfortunately, there is no in-game way to view this data. Not directly, at least...
There is a JSON file which supplies the app with partial amounts of map data (data correlating to a 20x20 grid on the world map). I want to use that JSON file to store those results in a spreadsheet so I have my own record of map details I can view locally and on a whim.
Here is an example of one of the JSON files containing map data:
http://realm3.castle.wonderhill.com/api/map.json
I'll be the first to admit I hardly have any programming knowledge. I'm a SQL expert, but that knowledge seems to be getting me absolutely no where in this endeavor... :(
Any tools you guys know of which would help me achieve my ends? I don't think what I'm asking for it all that uncommon or complicated, but I cannot find a solution for the life of me.
Any help is greatly appreciated.
Hopefully the code below will get you started. Basically $jsonurl is the URL you want to call to get the map data. $json actually gets data. $json_output turns it into an array. You can then work with those arrays to insert that data into MySQL:
$jsonurl = "http://realm" . strval($realm['intRealmID']) . "." . $realm['strRealmServer'] .".castle.wonderhill.com/api/map.json?x=" . $x . "&y=" . $y . "%26timestamp=" . time() . "&_session_id=INSERTYOURSESSIONIDHERE5";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json,true);
Related
I am new to symfony and open-source in general. Im trying to create a simple product submition page which would store product's information in mysql. So far I've only been able to hard-code all the information and successfully store it (this was my first task to achieve). This is the code for it:
public function createAction()
{
$product = new Product();
$product->setName('Keyboard');
$product->setPrice(15.50);
$product->setDescription('Logitech keyboard v2.00');
$em = $this->getDoctrine()->getManager();
$em->persist($product);
$em->flush();
return new Response("Saved new product with: " .$product->getId() ."Id");
}
Now I want to have a page with couple text boxes and to be able to take this information, validate it and then store it. What would be a clever way to do it? As I'm learning for my internship, I want to be able to do it in a best possible way. Are twig templates the best solution here? What about fetching user's input? I would be really thankful if someone could write step-by-step bullet points on how to achieve my goal in abstract sentences. Thank you and have a great remaining Friday!
1) One of the best and yet simple ways for you to start your mission would be by reading Symfony book chapter about Forms. It contains basic examples about form rendering, validation and submission using twig.
2) If you need to know more about how to save everything to database and would like to use Doctrine (most common way) then this chapter covers it in detail and is also not too deep to make it easy enough.
3) If you would like to deepen your understanding of Validation then you should definitely read about it too
http://symfony.com/doc/current/book/forms.html
http://symfony.com/doc/current/book/doctrine.html
http://symfony.com/doc/current/book/validation.html
I have a mapbox, and want to display a layer of esri data onto it. The data I'm getting is being pulled in from this json file:
https://gis.usps.com/arcgis/rest/services/EDDM/selectZIP/GPServer/routes/execute?f=json&env%3AoutSR=102100&ZIP=93003&Rte_Box=R&UserName=EDDM
The data['results'][0]['value']['features'] array looks something like this:
[{'attributes': {'key':'value'}},{'geometry':{'paths':[[-13273770,4064608],[-13273762,4064613],....]}},
{'attributes': {'key':'value'}},{'geometry':{'paths':[[-13273770,4064608],[-13273762,4064613],....]}},
{'attributes': {'key':'value'}},{'geometry':{'paths':[[-13273770,4064608],[-13273762,4064613],....]}}}]
My question is about the geometry array. The data there is not Lat/Lng values (which I was hoping for), so I'm not sure how to add these to my map. I'm new to GIS, and the research I've done so far points to SpatialReferences. Any help is obviously much appreciated!
MapBox seems to only accept Latitude and Longitude coordinates (from what I can tell at least). The coordinates you have in your file come from ESRI 102100 (3857) projection system - the clue is near the beginning of your file:
"spatialReference":{"wkid":102100,"latestWkid":3857}..."
Normally, you'd have to convert this yourself, a good link for potential tips in the future is:
https://gis.stackexchange.com/questions/9442/arcgis-coordinate-system
On this occasion however, you can do something far easier. Simply change the "outSR" property of your URL from 102100 to 4326 (WGS84) and let it do it for you.
https://gis.usps.com/arcgis/rest/services/EDDM/selectZIP/GPServer/routes/execute?f=json&env%3AoutSR=4326&ZIP=93003&Rte_Box=R&UserName=EDDM
I am working on a fairly simple Heat Map application where the longitude and latitude of the points will be stored in a SQL Server database. I have been looking at an example that uses an array of objects as follows (eliminated a lot of data for brevity):
/* Sample data to demonstrate Bing Maps Heatmap */
/* http://alastair.wordpress.com */
var CrimeData = [
new Microsoft.Maps.Location(52.67280, 0.94392),
new Microsoft.Maps.Location(52.62423, 1.29493),
new Microsoft.Maps.Location(52.62187, 1.29080),
new Microsoft.Maps.Location(52.58962, 1.72228),
new Microsoft.Maps.Location(52.69915, 0.24332),
new Microsoft.Maps.Location(52.51161, 0.99350),
new Microsoft.Maps.Location(52.59573, 1.17067),
new Microsoft.Maps.Location(52.94351, 0.49153),
new Microsoft.Maps.Location(52.64585, 1.73145),
new Microsoft.Maps.Location(52.75424, 1.30079),
new Microsoft.Maps.Location(52.63566, 1.27176),
new Microsoft.Maps.Location(52.63882, 1.23121)
];
What I want to do is present the user with a list of some sort that displays all the data sets that exist in the database (they each have a name associated with them) and then allow the user to check all or only a select few. I will then need to generate an array like the above to create the heat map. Any ideas on a good approach to this?
What you trying to achieve is more related to a web developement rather than only related to Bing Maps.
To summarize, you have multiple ways to do this but it really depends on what you are capable to do and what you need in the interface.
What process/technology?
First, you need to determine what process you want to follow to display the data and it will set the technology that you will use. The questions that you need to ask yourself are:
Do you want to be able to change the data sets dynamically without refreshing the whole page?
If yes, it means that you will have to use asynchronous data loading through a dedicated web service in order to avoid loading all the information at the initial load of the page.
Do you have lots of data to load?
If so, it might comfort you with asynchronous loading to avoid loading all data.
If not loading every elements in multiple arrays might be the simplest solution.
Implementation
So now, you want to create a web service to load the data asynchronously, you can take a look at the following websites :
http://www.asp.net/get-started
http://www.stefanprodan.com/2011/04/async-operations-with-jquery-ajax-and-asp-net-mvc/
There might be interesting other website, you will be able to find them. If needed, add comment and I'm sure the community will help you.
If you want to generate the data directly in the script, it could be simple as you can compose the JavaScript directly in your dynamically created HTML page (in your ASP.Net markup code or whatever technology you're using).
To this topic I have found a very good and helpful entry:
Map View draw directions using google Directions API - decoding polylines
But I have a question to the answer of Kenny.
He has written a function called decodeZoomLevels(String encodedZoomLevels)
and what paramenter is the encodedZoomLevels?
As my direction API response I get a polyline entry like this:
.
.
.
"polyline" : {
"points" : "grheHevjqAo#i#WMm#]a#QUGoAKqAG{#Ea#Ge#E]Im#Wa#Ou#Uy#MEI]OAICGEECAGAG#A#A?CBABAFc#HOJeB?}FNiBHaENw#Be#Bc#Ee#Gq#Wo#[w#i#[c#c#q#mAgC_#u#e#{#aA{Ai#k#u#w#c#g#w#gAiAqBMUEIaCsEmBuDqBqEkAyB{#gASWs#s#aBcBc#o#g#{#_#w#c#m#USWOg#O_#E}AGS?UA[COCe#O}#s#q#kA[aAUuASmAS}#So#IOQYc#s#w#u#u#Y"
},
.
.
.
As you can see the polyline entry has only another entry called "points", but wehere is the entry "zoomlevel" as Kenny is describing?
Hope you can help.
Zoom levels is the array of integers, where each number control the appearance of points in different zoom levels. In other words, if it is present, it can reduce number of points visible in lower zoom levels, but allowing to show more details when zooming in. It is not generated automatically, and I suppose to generate such a feature you need to implement polygon reducing algorithm.
Do you really need it?
Read more in google's manual.
I have real-time GPS data stored in a database and I'm currently pulling the lat/lon from this data and dynamically displaying them as markers on a Google Map.
What I'm trying to accomplish is to use these lat/lon points to draw a path connecting them. I looked at GDirections, but that seems like it's only used to connect two points together. I'm looking for something where I can send a bunch of GPS coordinates, from start to finish, and have it draw the path on the map connecting them.
Any guidance is greatly appreciated.
Apparently it was a lot easier than I thought.
The following will do the trick:
echo "var polyline = new GPolyline([new GLatLng($startlat, $startlon), new GLatLng($endlat, $endlon)], \"#ff0000\", 10);";
echo 'map.addOverlay(polyline);';