[OpenLayers-Users] Importing JSON to WKT

Joel Leininger leiningr at gmail.com
Tue Jul 10 12:24:51 PDT 2012


Firebug says polygone remains undefined, as if the line of code were
ignored. No error message is thrown. In experimenting yesterday, I cut and
pasted the Multipolygon string into the parcer.read line and it worked.
Then I created a variable called wktTest and assigned the Multipolygon
string to it, then ran

var polygone = parcer.read(wktTest);

and it didn't work: polygone remained unassigned. Now that last test would
seem to indicate that Json is not part of the issue here, but something
having to do with that read property. No variable would work; all literal
strings, however, moved the geometry object to polygone.

The coordinates are correct, by the way. All the translations happen at the
postgis level, and when I pass a Multipolygon literal string it plots in
the correct place on the map. On that score we're good.

I'm just stumped on that read statement quirkiness.



On Tue, Jul 10, 2012 at 2:43 PM, Greg Allensworth <gregor at greeninfo.org>wrote:

> On 7/10/2012 11:21 AM, Joel Leininger wrote:
>
>> Okay, here is that output:
>>
>> Object { status="added", numResults=1, 0=[1]}
>> ["MULTIPOLYGON(((-8528843...**591 4765443.37168208)))"]
>>
>> That looks right to me. Not sure of the nomenclature "0=[1]" but [1]
>> could reflect the wkt object. The second line is what I'm trying to feed
>> into the read statement, and it looks correct -- except the brackets.
>> Does firebug add those or would they be in the json?
>>
>
> The brackets indicate that it is an array. Which is good, as you were
> expecting an array with 1 element, and for that one element to be a WKT
> string.
>
> So, when it gets to this line, what does it do? What is the value of
> polygone afterward? You mention that it doesn't process, but not what it
> really DID.
>
>    new polygone = parcer.read(updateOutput[0]);
>
> Also, I notice that the coords in the WKT are not Lon/Lat coords; perhaps
> Web Mercator? If you're expecting the coords to be in Web Mercator, that
> looks right; if you're expecting latlon, you may want to double-check.
>
>
> --
> Greg Allensworth, Web GIS Developer
> BS  A+  Network+  Security+  Linux+  Server+
> GreenInfo Network - Information and Mapping in the Public Interest
> 564 Market Street, Suite 510  San Francisco CA 94104
> PH: 415-979-0343 x302  FX: 415-979-0371    email: gregor at greeninfo.org
> Web: www.GreenInfo.org     www.MapsPortal.org
>
> Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120710/c04b7670/attachment.html>


More information about the Users mailing list