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 ...


4

A quick solution to serve up shapefiles on a basemap in a webapp is through a free arcgis.com account. They allow you upload .shp files, symbolize, and lay them on a base map. The share tool allows provides a html script that can be copied. I served up some symbolized counties to my blogger page in a webmap. Note that ESRI is trying to monetize arcgis.com ...


4

This depends on what you want & need. Do you only need "dead" bitmaps, or do you need "alive" objects in your client? There are numerous solutions out there, depending on your needs. You need a client in your browser, OpenLayers is perhaps the most prefered open source solution. As for the service backends, e.g WMS and WFS, Geoserver and Mapserver ...


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.


3

You can convert the shapefiles to geojson or gml or kml. After that you can use and tweak the examples in OpenLayers or Leaflet to display your data.


2

A internet search on PHP and projection turned up a PHP port for PROJ.4. proj4php The page says that it's a translation from a Javascript version of PROJ.4. I'm not familiar with it so I can't give you any more details.


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

First of all, because the radius is expressed in meters, you need to convert/transform your data in a projected coordinate system. For instance, if lat and lon are geographic coordinates in WGS84, you could use the UTM WGS84 ...something. Then, I would use this solution: http://math.stackexchange.com/a/256123


2

You can load dynamically (with ajax) your PHP file and set the content into testData var, as in your previous script. Then execute your original script without any changes. Note that you will use $.ajax() jquery method to be able to set 'async': false option. var testData = (function () { var testData = null; $.ajax({ 'async': false, 'global': ...


2

for a quick solution, you can check out shapefile-js. A binary shapefile loader and canvas-based renderer, for javascript. Many caveats. test it: http://www.prodevelop.es/files/fm/public/downloads/jldominguez/shp.html more info: Rendering local shapefiles with HTML5 http://www.prodevelop.es/en/blog/11/12/11/rendering-local-shapefiles-html5 and my ...


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

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

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

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

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

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.


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 ...


1

You have to use a blob type column in MySQL to store the image. Your php script then needs to present that blob as read from the MySQL table to the JS Script with the correct Mime Type. I cannot give you any example code as I work in ASP, but the concept is the same. This might help you along. Read from the Blob, write using a streamwriter with the correct ...


1

This is a pure PHP polygon class that offers many geometric operations such as union and intersect. The library is released under GNU license. http://www.phpclasses.org/package/2544-PHP-Perform-geometric-operations-on-polygons.html


1

You may use GeoTools, which is an open source java toolkit, for doing your union/dissolve process, check out this Q/A: combine several polygon objects in one polygon object with geotools (is it possible)?


1

You can change the fill color of a polygon with the setStyle method (inherited from Path). polygon.setStyle({fillColor: '#0000FF'}); If you're having difficulty getting the geojson displayed properly you might take a look at the Leaflet GeoJSON docs.


1

A spatial DBMS is usually (an extension to a) traditional, relational DBMS. It provides At least a Point data type (X, Y) or (lat, long) and often Line and Region types. A spatial indexing option such that queries seeking records that are geo-located within a simple bounding rectangle can be answered quickly. Such databases may also vary according to ...


1

$layer = $map->getLayerByName('layername'); //set an attribute value $layer->set('data', '/path/to/my/shape/file.shp'); or $layer = $map->getLayer('layer_index'); //integer! //set an attribute value $layer->set('data', '/path/to/my/shape/file.shp');



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