Tag Info

Hot answers tagged

5

Your generated GeoJSON is valid JSON, no problem. But, it's not valid GeoJson, as you can see here: http://geojsonlint.com/ The problem seems to be that the features-array in your featurecollection contains three features, two with geometry:none and one with just geometry (which is also string-encoded). So, in short: Your OpenLayers-code seems fine, the ...


5

This only a partial answer and lacks all python but too long to fit into a comment field. Your data is rather easy to convert into WKT: capture the coordinate part switch commas to spaces and spaces to commas close inside WKT polygon: POLYGON ((...)) POLYGON ((39.655756 -4.034769,39.655757 -4.034769,39.655758 -4.034769,39.655800 -4.034788,39.655885 ...


4

Since your search region is circular, it is perhaps best not to consider it to be a polygon, but as a point with a radius and to use the ST_DWithin() function: ST_DWithin — Returns true if the geometries are within the specified distance of one another. It should save you and the processor a lot of effort.


4

If you want to make browser download the generated KML, an extra header is needed: header("Content-Disposition: attachment; filename=MY_KML_FILENAME.kml"); Otherwise, just ignore the message, it's harmless. Chrome doesn't recognize the KML-specific Content-Type, and expects ordinary text/xml or application/xml, but since it's all XML, it should be parsed ...


3

How do spatial algorithms help? There are many ways spatially based algorithms can improve upon traditional algorithms. Often, you can use spatial algorithms to drastically lower the amount of records you have to loop through, such as when using distance in your calculation. Give me an example! Let's use this question that was asked today as an example. ...


3

I'm assuming that your 'rectangle' is in 2D, and not wrapped around the earth. Suppose you have the Center at x and y. And your Height & Width are h & w. In that case, simple arithmetic will give you: min_x=x-(w/2) min_y=y-(h/2) max_x=x+(w/2) max_y=y+(h/2) These four values will give you the four coordinates.


3

You could use TileMill to make tiles as MBTiles: https://www.mapbox.com/tilemill/ Then use something like python-mbtiles to serve it up: https://github.com/perrygeo/python-mbtiles.


2

Please check out https://github.com/klokantech/tileserver-php/ might be helpful for you.


2

If you have tiled map in MBTiles format, you can serve them using ordinary PHP script. All you need is php-sqlite module, which should be included by default. You can try this: mbtiles-php - I'm using similar script in production. With some kind of URL-routing library, you can even simulate standard TMS. Actually, you also can write your own WMS ...


2

I think GeoMajas is a good choice. For routing purposes I want to introduce you Graphhopper. It's still a young project, but it's java, it's incredibly fast and there are ready to use applications to route either on a web server or on the mobile device itself based on openstreetmap data. So if you have no problems to use openstreetmap and want to route on a ...


2

Try here: Integrate GeoJSON file with openlayers.protocol.http See my answer (the accepted one). The code will solve your problem for sure. After all, try to access your URL (gj/DB2GeoJson.php) using the browser and check it here : http://json.parser.online.fr/ Check for blank spaces and strange characters (PHP is the winner in messing html things). Don't ...


2

The error was actually happening where the sql command was generated at this line of code: $sql = "SELECT " . pg_escape_string($fields) . ", st_asgeojson(transform(" . pg_escape_string($geomfield) . ",$srid)) AS geojson FROM " . pg_escape_string($geotable); Turns out that there is a bug in the code presented here, and the correct name of the transform ...


2

The first thing to do is to display the returned error as follow. You should then be able to find the error : # Try query or error $rs = pg_query($conn, $sql); if (!$rs) { echo "An SQL error occured.\n"; echo pg_last_error($conn); exit; }


2

I found the correct answer here ... it's tested many times and works like a charm http://tutorialspots.com/php-detect-point-in-polygon-506.html


2

Although your question probably is harder than it seems due to curvature (spheical trig) issues, if you're happy to ignore that, there are a few ways to do a point-in-polygon check. I've used a ray casting algorithm, and you should be able to find example code somewhere to do that. If you're using Python, just use Shapely. If Javascript, here's some code.


2

a simple algorithm would consist in checking that you are on the "good" side of the lines that build your polygon. For instance, the long of your point has to be larger than the long of the West side and smaller than the long of your East side at the lat of your point. e.g. Long_point > Long_LowerLeft + Lat_point * ( Long_UpperLeft - Long_LowerLeft)/ ...


2

PHP knows nothing about the SQL query sent to PostGIS. Therefore, it doesn't matter if you have nested queries or not. But it is very important for PostGIS, in order to perform the query, to receive a valid query, like you did when you have used PgAdmin. So, I think you need to revise your php $sql variable, like this: $sql = "SELECT name, ...


2

You would need to georeference (that's the term) image with QGIS. See my answer to this question for tutorial links.


2

If you're looking for geojson support, I would go for builtin PostgreSQL capabilities instead of parsing it with PHP. It's available since version 9.3 and it works like charm with Leaflet library. You'd also probably need to do some routing if you want to build a RESTful app and you might find any of these PHP framework handy.


2

As @tmcgee points out in the linked answer, the list of basic base maps that can be passed to the constructor are set in the esriConfig defaults object. It's not that the error message needs to be updated, it's that the constructor can only be passed a value in this list and that doesn't include an entry for the Terrain with Labels basemap. I've handled ...


2

This article on the marching squares algorithm outlines the general algorithm. Here is a good implementation, in various languages, though sadly not Python. Having said that, the algorithm basically just operates on arrays in loops, so ought to be reasonably easy to port. I have used the Java version to do contours and can confirm that it works, in the ...


2

I think the best approach is to go with Mapserver or Geosever (since you are new, Geoserver will look a lot easier) Once you set a WMS service with geoserver, you can add the resulting WMS to your OpenLayers project. Geoserver automatically returns only the information in the extent of the current view, also you can set the range of visible scales on your ...


1

I suppose you have been reading this http://docs.geoserver.org/latest/en/user/tutorials/cql/cql_tutorial.html Here comes some sample requests which are sending queries for the demo server of Boundless but which should work similarly with your own server if you have demo layer topp:states installed. Select where STATE_NAME is Illinois ...


1

This sort of thing is what humans are good at but computers aren't good at. One approach that may help is sorting the points in clockwise order, this will give you mostly what you want but will still need some manual intervention with a software package like ArcGis or QGIS. In essence find the leftest point (lowest X), if two are colinear then the one with ...


1

Theres a "kind of" API (read: some features are available through HTTP requests) described at http://geonetwork-opensource.org/manuals/trunk/eng/developer/xml_services/index.html . From that document: Url: http://localhost:8080/geonetwork/srv/eng/xml.search Mime-type: application/xml Post request:s <?xml version="1.0" encoding="UTF-8"?> ...


1

This is a two step process: Using ArcGIS for Desktop export a single Layer to KML or a whole Map to KML Display your KML in Google Maps - perhaps using Google Maps JavaScript API v3.


1

OpenStreetMap uses boundary relations for defining borders for areas/territories/jurisdictions and similar administrative things. So you have to look for relations tagged with boundary=administrative and certain admin_level=* values.


1

You may possibly want to look into querying against Nominatim. https://github.com/kenguest/Services_Openstreetmap - a php based library for interacting with both the main OSM api and Nominatim api also might be of interest to you; specifically the getPlace method. (disclaimer/disclosure: I'm the author.) As a very quick proof of concept, you could model ...


1

first , you don't have geometry class in php (i don't know how to get one). Second georaphy is not geometry type in database , those two types are different. WKT for POLYGON seems to be wrong, should be like 'POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10)) (thats how i got my test case working) $params = 'geometry::STGeomFromText('POLYGON ...


1

Yes, it is possible. But what is the source of layer list? If that information is stored in a some kind of database, then PHP will be the right way. But when you want to load all layers from WMS server/workspace, then AJAX call to GetCapabilities or GeoServer API will be better. Last but not least, if layer list is immutable, this could be done entirely in ...



Only top voted, non community-wiki answers of a minimum length are eligible