On Mon, Oct 18, 2010 at 7:35 AM, Richard Greenwood
<[email protected]> wrote:
> On Sun, Oct 17, 2010 at 7:17 PM, P Kishor <[email protected]> wrote:
>> I have created a control after the "OpenLayers Measure Example"
>> [http://openlayers.org/dev/examples/measure.html], and all is good.
>> The user can draw a poly in the browser, and measure the area. Now, I
>> want to save the drawn polygon on the server-side, so I can recreate
>> it later. I guess if I could convert the drawn poly to a geojson
>> object, I could save it on the server. Then, at the click of a button,
>> the saved map extent and the drawn feature could be recreated. Any
>> ideas how I could do this?
>
> Puneet,
>
> I send the object to a PHP script on the server and save it into a
> PostGIS database.

Right, but what is the call for getting the object from the OL client?
I guess I should simplify my question by breaking it up into two parts
--

1. Once I have drawn a poly on the map (using the measure control),
how do I get its geometry that I can then send to the server? All I
need to know here is the appropriate method that will give me the
geometry of the poly I drew.

2. What all are the essential params required to reconstruct the state
of a map view in OL? I guess I need to know the layers that are
visible, and the map extent that needs to be saved. In my use case,
since I also want to reconstruct the poly that was drawn, I need that
geometry. The last I can get via #1 above, but how do I get the
"current" map extent and the names of the layers that are currently
visible? Is there a method that can "dump" all the information
required to reconstruct the current state?

> I don't use GeoJSON or any standard format, but
> probably should.

What format do you use?

> Do a POST not a GET as geometries can become quite
> big. And I always do an ST_ISVALID() before inserting it. If you're
> working with polygons it is not uncommon for the user to draw an
> invalid poly and there is nothing to stop that poly from being
> inserted. It is only when you query that invalid poly that the
> problems begin. If you're only working w/ lines and points then it's
> not a worry.
>
> Similarly, I query a PHP script for an object's extent using the
> PostGIS ST_EXTENT() function, and pass that to OpenLayers. ST_EXTENT()
> is an aggregate function, so you can pass a set of records and get the
> bounding box of the whole set, e.g. if you had a bunch of address
> points:
>  SELECT ST_EXTENT(wkb_geometry) WHERE zipcode='83014';
> Would return the bounding box of the whole set of matching points.
>
> In both cases (saving and retrieving) I'm using home grown AJAX calls
> to home grown PHP scripts. I'm sure others will suggest WFS-T which
> has it's strengths, but forces you into WFS. I'm doing everything with
> native MapServer layers.

Simple is better. I am sticking to WMS with MapServer. For geographic
data I have a mix of shapefiles, images, and PostGIS. For everything
else, I am using SQLite (for now).

Its all working quite well.

>
> Regards,
> Rich
>
>
>> --
>> Puneet Kishor http://www.punkish.org
>> Carbon Model http://carbonmodel.org
>> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
>> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
>> Nelson Institute, UW-Madison http://www.nelson.wisc.edu
>> -----------------------------------------------------------------------
>> Assertions are politics; backing up assertions with evidence is science
>> =======================================================================
>> _______________________________________________
>> Users mailing list
>> [email protected]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>
>
>
>
> --
> Richard Greenwood
> [email protected]
> www.greenwoodmap.com
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to