On Mon, Oct 18, 2010 at 8:55 AM, P Kishor <[email protected]> wrote:
> On Mon, Oct 18, 2010 at 8:36 AM, David Fawcett <[email protected]> 
> wrote:
>> Puneet,
>>
>> I know that you are using php and not Python,
>
> Thanks David, but I am not using either PHP or Python. I am a Perl guy
> through and through. Never used anything else. But, that is not really
> relevant here.
>
> I guess what I am looking for is access the to polygon that I just
> drew using the measure control. Obviously, it has been drawn on the
> map by OL. Surely it must be accessible somehow. I just can't figure
> out how.


With following code, I can see that OpenLayers.Geometry objects are
being created

        handleMeasurements: function(event) {
            var geometry = event.geometry;
            console.dir(geometry);


Output in Firebug
-------------------------

"OpenLayers.Geometry.LinearRing_280"
parent
        POLYGON((-10057484.328527 5739795.8538497,-10058707.320949
5776485.6265059,-10018960.067238 5777097.1227169,-10019571.563449
5734903.8841622,-10057484.328527 5739795.8538497)) {
id="OpenLayers.Geometry.Polygon_279", more...}



So, what I need to do is grab the final poly object (for now, I am
only interested in the polygons that are drawn to measure area), and
convert it to GeoJSON.

>
> Looking at the GeoJSON example, it seems that if I have a GeoJSON
> object, I can create a poly out of it. So, putting the two together,
> it seems natural that if I could save my drawn poly as GeoJSON, I
> could draw it back out again at a later time.
>
>
>> but you may want to look
>> at FeatureServer  http://featureserver.org/.
>
> Aiiiiiieeeee.. not another technology. I haven't looked at
> featureserver, so I know nothing about it. But my first, gut reaction
> is that I don't want to implement another technology. I am very happy
> with the mix of stuff I have going.
>
>
>>
>> David.
>>
>> On Mon, Oct 18, 2010 at 7:50 AM, P Kishor <[email protected]> wrote:
>>> 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
>>>
>>
>
>
>
> --
> 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
> =======================================================================
>



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