Hot answers tagged

6

It seems you try to persist your entity and its id remains null. That's why your get a constraint violation error. To simply solve this error I suggest you to try create your database table using auto-incrementation option on your SHAPE field. It should solve your problem, I guess. OR Reading the documentation on LAST_INSERT_ID() I would suggest that the ...


5

This is quick and dirty. Most of this was adapted from the following website: http://www.movable-type.co.uk/scripts/latlong.html I haven't tested this too much but it seemed to work after initial testing. It will return a list of lat, long coordinate pairs along a line at a specified interval. I wrote it in python since I don't know php very well. from ...


4

In line $polywrite = "<script>document.write(polygon)</script>" you are trying to use javascript code while it is imposible in php side. All php scripts run before javascript. You can use proj4php as mentioned in the comments. Another solution is to fill the polywrite variable at javascript side and create an Ajax request sending `polywrite' to a ...


3

See code example Leaflet users map https://github.com/bmcbride/leaflet-users-map by Bryan McBride. There is used SQLite DB, but her easy replace on MySQL.


3

I would recommend to rely on GeographicLib implemented by Charles Karney which uses Gnomonic projection for point to line projections in WGS-84 (http://geographiclib.sourceforge.net/). This solution is discussed and proven to be highly accurate in Charles Karney, Algorithms for geodesics (http://link.springer.com/article/10.1007%2Fs00190-012-0578-z). A ...


3

Basically you just need a PHP script that acts as a middle man and does the fetching for you, then returns what it gets directly to the client. I converted your JS snippet above into the relevant parts below. Notice that the url in your Leaflet tileLayer example has been changed to a PHP endpoint with URL parameters: ?s={s}&z={z}&x={x}&y={y} ...


2

Yes you can get them to work together. Below is a sample of code from a php page I coded that uses proj4js, mine is slightly different going from a state plane into wgs84 but the concept is the same. (The syntax is a little off as I had problems pasting it into a code block and my code is sort of spread all over the place in a couple php files but I think ...


2

I did port the Python code to php: <?php function parseFloat($ptString) { if (strlen($ptString) == 0) { return false; } $pString = str_replace(" ", "", $ptString); if (substr_count($pString, ",") > 1) $pString = str_replace(",", "", $pString); if ...


2

Since this question was tagged with Java, I'd put my weight behind Conveyal's gtfs-editor, a webapp which runs on Java via the Play framework. It's pretty easy to get going if you're familiar with CLI. https://github.com/conveyal/gtfs-editor


2

Yes, you can do it. Just render the HTML you need in the view and "inject" that code in the visualization infowindow template. For example: ... layer.infowindow.set('template', document.getElementById('infowindow_template')); ...


2

Over at GeoNet, Junshan Liu pointed out the following. This is caused by getPath function in env.js. In this function there is path check /\.html$/.test I found that on line 162 in env.js and changed it to ... } else if (/\.php$/.test(fullPath.split('/').pop()) || /\.html$/.test(fullPath.split('/').pop())) { And that now allows me to load either ...


2

I depends on how you create or add the table to the database. If you upload your table to the database through any tools like shp2pgsql or QGIS a geometry column is made for your to store the spatial data in. You will need to manually create the geometry when inserting to the database. INSERT INTO mytable(mycol1, mycol2, geom) VALUES(1, 2, ...


2

If you've already got WKT, then you might considering using the JavaScript library, Wicket, to go straight from your WKT to Leaflet features. As this example shows, you can pass in a WKT string and a style/options object, and Wicket will return a feature object you can attach directly to a Leaflet FeatureGroup, etc. This example assumes two things: 1) You ...


2

You were almost there... MultiPolygonZ should do the trick: ALTER TABLE urbana_prueba ALTER COLUMN geom TYPE geometry(MultiPolygonZ, 3857) USING ST_Force_3D(geom);


1

The following query solve my issue SELECT name, area, district, ST_Distance_Sphere(geom,'POINT($longitude $latitude)'::geometry) as distance FROM poi ORDER BY poi.geom <->'POINT($longitude $latitude)'::geometry LIMIT 1;


1

I assume you can't change the setup with the two databases. So let's take this as a given. Your postgis query is very inefficient. Although you only display the first row it still computes distances to all points in the table. Is there a max distance you want to search in? You could add a where clause to limit the calculation to points which intersect with ...


1

Make the layer you want to export the active layer, and paste following code into python console (or execute as script): fn = 'E:\\test.txt' f = open(fn, 'w') for feat in layer.selectedFeatures(): f.write('[') for p in feat.geometry().asPolygon()[0]: f.write('[\"lat\"=>{0:.5f}, \"lng\"=>{1:.5f}], '.format(p[0], p[1])) f.seek(-2, 2) ...


1

This can be relatively simple for very small scale systems (e.g., one route and bus), but gets more complex as more buses and routes are introduced. First, you need an app on a device to send vehicle position data - from this post on the onebusaway-developers group: https://groups.google.com/forum/#!topic/onebusaway-developers/JzYMwLFCpT0 See this post ...


1

The problem was related with the security authentication of PostgreSQL. After adjusting this in the configuration of the database I was able to login automatically using this: shp2pgsql -s 2100 -d /var/www/dkar/MarCO/Code/python/output/cluster/clusterNodes_.shp | psql -U username -d databaseName Hope this helps someone.


1

Yes this can be done using http://proj4js.org/ you can find your parameters here http://spatialreference.org/ the rest is just code. I have a similar php script in a web page that converts from State Plane Coordinates into Lat/Long EPSG 4326. It basically follows this logic, ignore the extraneous stuff, that i think can be applied to your problem. ...


1

I've solved putting $db->loadExtension('mod_spatialite.so'); in my PHP code and configuring the LD_LIBRARY_PATH env variable in thsis way export "LD_LIBRARY_PATH=/usr/local/lib"


1

by including the email parameter in my request, nominatim osm server acccepted that as a valid user agent. $url = "http://nominatim.openstreetmap.org/reverse?email=myemail@myserver.com&format=xml&lat=-23.56320001&lon=-46.66140002&zoom=27&addressdetails=1"; Nominatim WIKI parameters


1

In addition to Wicket, there is also Wellknown // With Leaflet or MapBox.js var geojsonLayer = L.geoJson(parse('Point(1 2)'));


1

Your code: Wont work because 'Incidents' isn't defined yet (hence your error message). Try running it without the 'Incidents' in here. Or drop your code into this section: function showIncidents(ajxresponse) { lyr.clearLayers(); lyr.addData(ajxresponse); } Something like this: function showIncidents(ajxresponse) { // Incidents geojson layer ...


1

As mentioned by TsvGis, you'll probably need to embed the font in the document. You appear to be using reportlab for this, check the FAQ on their site, they have an example of how to embed fonts - section 2.6.2 Be aware that there might be licensing issues on some commercial fonts (they may not embed properly). If this is the case there are plenty of ...


1

If you have access to the Geocortex Site, then the easy way to consume your data is by using a Workflow to make the web request from the Geocortex Essentials server, which can then create a new Graphics Layer and add it to their map. If you don't, then making a WMS server is one option. However, it would be simpler to generate a GeoRSS feed of your points ...


1

PHP exec() should work, what error do you get? And what commands/utilities are you using to convert? For example with ogr2ogr: $command = "/usr/bin/ogr2ogr -f GeoJSON output.geojson input.shp"; exec($command); You should use escapeshellarg if any of these params are coming from user input


1

You have to convert the received unreadable data to hexadecimal string. You will get this 24 41 20 20 67 72 51 30 35 41 68 40 2018 29 fffd fffd fffd ff ff fb ff ff fffd fffd fffd fffd b0 23 7e c0 201a a1 55 Then you can split it and parse it like this. First 2 digital(24), stand for standard mode next 10 digital, is device'ID (41 20 20 67 72) 6 digital, ...


1

First of all, You need to add a new environment variable called PGPASSWORD $ export PGPASSWORD='password' But, if you try to set as usual, the www-data doesn't see the variable, so you need to add the line PGPASSWORD='password' to the /etc/apache2/envvar. Test if this works typing: sudo -u www-data bash -c "<the_command_shp2pgsql>" Then ...


1

If you get results from your php code, copy that json result into the tester on geojson.io or geojsonlint.com to check the format, once you confirm the data, take a close look to the "coordinates" values, sometimes PostGIS brings that data in a format that leaflet cant draw. If coordinates are alright, then someting in the code html code is the problem. One ...



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