Hi, I would suggest to use st_asgeojson to the geometry at the query level. Then in php, decode the geometry, build a new array with attributes and geometry, and finally encode everything to json.
Cheers, Hugo On Tue, Nov 15, 2011 at 7:13 PM, Robert Buckley <[email protected]>wrote: > Sounds easy....any chance you could write a tutorial using simple examples > we could build on? > > yours > > Rob > > ------------------------------ > *Von:* Adam Eskreis <[email protected]> > *An:* Nicholas Efremov-Kendall <[email protected]> > *Cc:* [email protected] > *Gesendet:* 19:31 Dienstag, 15.November 2011 > *Betreff:* Re: [OpenLayers-Users] Open layers with postgis > > Hello Aditya, > > I do what you are wanting to do nearly every day at my job. Here are a > few tips to help you get started: > > 1. The first thing you need to do is set up a connection to your > PostgreSQL database. Once this is complete, we can get started > 2. Next you are going to want to retrieve your data and pass it to the > frontend. Assuming you already know how to do a spatial query, I would > pull whatever data you want from the database, parse it into an array and > echo it out using json. > 3. Once you have your json on the frontend, you just loop through the > array and plot the data as you need. > 4. The geo-data will come back from PostGIS as either Well Known Binary, > or Well Known Text, depending on how you chose to retrieve it. WKB is > faster, but is harder to parse, and WKT has built in support in OpenLayers. > (have a look at the OpenLayers.Geometry.fromWKT function). I recommend > pulling in the data as WKT for starting out, and as you get more familiar > you can work on writing a WKB parser. > 5. If you need help using spatial queries, I would consult the PostGIS > guide before continuing wiht anything, however the main functions I would > recommen dlooking up are: > distance > within > contains > intersects > astext > > These functions will encompass most spatial queries you need to execute. > > Hope this helps, > -Adam > > > > > On Tue, Nov 15, 2011 at 8:08 AM, Nicholas Efremov-Kendall < > [email protected]> wrote: > > I have an ajax app the querries mysql and returns the results as GML. If > you like, I can share the code with you, > > > On Tue, Nov 15, 2011 at 2:15 AM, adams <[email protected]> wrote: > > Oh sorry, > I apologize, the correct URL is: > > http://www.openlayers-buch.de/beispiele.php > > > (@Bart 403 only for you - today because of the football match, thanks > for the hint) > > Regards, Till > > On 15.11.2011 09:08, Bart van den Eijnden (OSGIS) wrote: > > Hey Till, > > > > that URL gives a 403 forbidden. > > > > Best regards, > > Bart > > > >> Dear Aditya, > >> > >> there is postgis console, which directly displays queries in OL - this > >> is a tool my colleague made for a german OL manual. > >> > >> See the stuff here: > >> http://www.openlayers-buch.de/beispiele/ > >> > >> go to chapter 9 (in germany only, sorry). > >> > >> You may also download the code from this page. > >> > >> Regards, Till > >> > >> > >> On 15.11.2011 08:54, Aditya Kumar wrote: > >>> Dear USers, > >>> I want to display the result of some queries from postgis using > >>> php.Can > >>> you suggest me some documentation for this so that I can go through > them > >>> and > >>> make my application? > >>> > >>> > >>> Aditya Kumr > >>> > >>> -- > >>> View this message in context: > >>> > http://osgeo-org.1803224.n2.nabble.com/Open-layers-with-postgis-tp6995410p6995410.html > >>> Sent from the OpenLayers Users mailing list archive at Nabble.com. > >>> _______________________________________________ > >>> Users mailing list > >>> [email protected] > >>> http://lists.osgeo.org/mailman/listinfo/openlayers-users > >>> > >> > >> -- > >> > >> > >> --> GO Mobile - jetzt WebGIS auch auf Smartphones <-- > >> ! Achtung - terrestris hat eine neue Adresse ! > >> > >> --------------------------------------------------------- > >> terrestris GmbH & Co. KG > >> Puetzchens Chaussee 56 > >> 53227 Bonn > >> Germany > >> > >> Till Adams > >> Geschaeftsfuehrung > >> > >> Tel: +49 (0)228 / 962 899-52 > >> Mobile: +49 (0)151 / 25394429 > >> Fax: +49 (0)228 / 962 899-57 > >> > >> [email protected] > >> http://www.terrestris.de > >> Amtsgericht Bonn, HRA 6835 > >> --------------------------------------------------------- > >> > >> Komplementaerin: > >> > >> terrestris Verwaltungs GmbH > >> > >> vertreten durch: > >> Hinrich Paulsen, Till Adams > >> _______________________________________________ > >> Users mailing list > >> [email protected] > >> http://lists.osgeo.org/mailman/listinfo/openlayers-users > >> > > > > > > -- > > > --> GO Mobile - jetzt WebGIS auch auf Smartphones <-- > ! Achtung - terrestris hat eine neue Adresse ! > > --------------------------------------------------------- > terrestris GmbH & Co. KG > Puetzchens Chaussee 56 > 53227 Bonn > Germany > > Till Adams > Geschaeftsfuehrung > > Tel: +49 (0)228 / 962 899-52 > Mobile: +49 (0)151 / 25394429 > Fax: +49 (0)228 / 962 899-57 > > [email protected] > http://www.terrestris.de > Amtsgericht Bonn, HRA 6835 > --------------------------------------------------------- > > Komplementaerin: > > terrestris Verwaltungs GmbH > > vertreten durch: > Hinrich Paulsen, Till Adams > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > > -- Hugo Martins LabNT - ISEGI UNL Campus de Campolide 1070-312 Lisboa N 38°43'56.84", W 9°9'35.74"
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
