OpenLayers Add-on and WKT

Hi,
first, thanks for that nice add-on.

Is it possible to use directly WKT geometry format with Vol ?
Something like myVectorLayer.addWKT(myWKT)

Best Regards
Leoze

Hi,

I have never used WKT, but I’d guess it should be rather easy to implement. OpenLayers appears to support it, so at least making read only graphics so that the WKT script would be passed for browser to parse should be very straight forward.

Another option would be to use some Java library to parse the WKT script and then add geometries with Java. This way one could make better interaction with the server e.g. for editing. Found at leas one such Java library:
http://en.wikipedia.org/wiki/JTS_Topology_Suite

Which ever is the preferred way for you, you should create an enhancement issue to the google code project.

cheers,
matti

Thanks Matti.

HI,

Don’t know if you took JST in use, but OpenLayers Wrappers now support simple “read only” WKT layers. It was easy to add while I created WFS layer support. New version is available in the Directory.

cheers,
matti

Hi Matti,
I tried the WKT Support and it doesn’t work

simple scenario:

OpenStreetMap as base layer

adding some VectorLayer works well
adding MarkerLayer works well

but adding WellKnownTextLayer fails

used this WKT String:
LINESTRING(8.887336 50.055967,8.888376 50.057001,8.888543 50.057247,8.888193 50.057068)
calculated from the same LatLon coordinates I used with VectorLayer and MarkerLayer

but all WKT positions always are drawn somewhere southwest of africa

see attached screenshots

do you have any idea what happened ? or any workaround to draw LineString on OSM ?

thx for help

ekke
…working with Florian on redVoodo (Open Source BusinessApps for Vaadin / OSGi)
12056.png
12057.png

found a workaround using PolyLine and setting the Points
now there are lines :slight_smile:

curious to know why WKT doesn’t work

ekke

Hi,

It looks like some sort of projection issue. The base map appears to be in 900913, but your coordinates more like WSG84 coordinates. Is there some API in WKT implementation where you could explicitly set your projection for WKT. I don’t remember and I don’t have the project open at the moment…

cheers,
matti

but same coordinates are working using VectorLayer with PolyLine.
…it’s not so important at the moment because I solved the issue using PolyLine vector

Hi,

I checked from the code (didn’t test), and it indeed looks like WKT converts points based on base layer. Should be fixed in:
http://code.google.com/p/vopenlayers/source/detail?r=101

cheers,
matti

great to hear - and thanks :slight_smile:

Hi Matti,

would be great if you could provide a r101 as download from your project site -
then I can test if it works.

thx again

ekke

Matti has made some changes - thx.

But I don’t get it run :frowning:
perhaps someone else has tried
r104
?

I’m doing it this way:

base layer OpenStreetMap
add WKTLayer
set some WKT coordinates as Linestring:


String wktText = “LINESTRING(8.887336 50.055967,8.888376 50.057001,8.888543 50.057247,8.888193 50.057068)”;
wktLayer.setWellKnownText(wktText);

but no map is displayed.

doing the same as a VectorLayer it works:
[font=Courier New]

    Vector line = new PolyLine();
    line.setCaption("Track 42");
    Point[] points = new Point[4]

;
points[0]
= new Point(8.887336, 50.055967);
points[1]
= new Point(8.888376, 50.057001);
points[2]
= new Point(8.888543, 50.057247);
points[3]
= new Point(8.888193, 50.057068);
line.setPoints(points);
waypointLayer.addComponent(line);

[/font]
have all needed scripts included in gwt.xml:

[font=Courier New]

[/font]


customprojections is in public folder and contains:
[font=Courier New]

Proj4js.defs[“EPSG:4326”]
= “+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs”;
Proj4js.defs[“EPSG:900913”]
= “+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs”;
[/font]

Debug says:

EPSG:4326 → EPSG:900913
POINT(12.127891 47.85603)
POINT(1350070.6505163254 6082936.690183788)

ClassCastException: null

any idea what could be wrong ?

thx

ekke

Hi,

Oh dear, was that really me who committed the last invalid fix to an invalid feature :slight_smile: I had earlier mixed to and from projections and now I forgot one getParent() call causing that class cast exception of yours. The issue should be now fixed. New snapshot is available, but I hope to bake up a new release today too. There are still several other feature in queue.

BTW. If you are only using EPSG:4326 and EPSG:900913 projections, you don’t necessary need proj4js. OpenLayers supports those by default. You only need proj4js if you use some more exotic projections.

__
cheers,
matti

Hi Matti,

thanks.

just first test with r109

the ClassCastException is gone :slight_smile:

but now:

EPSG:4326 → EPSG:900913
POINT(8.888185 50.056999)
POINT(989428.2282764124 6456152.921560051)

JavaScriptException: (TypeError): ‘undefined’ is not an object

Processing time was 586ms for 4570 characters of JSON
Referenced paintables: 1172

Hi,

How does your case differ from this:

http://code.google.com/p/vopenlayers/source/browse/trunk/src/test/java/org/vaadin/vol/demo/WktCaseEkke.java?spec=svn112&r=112

I just run in on the latest trunk it seems to work fine. There were some changes, but none of them should have affected this.

cheers,
matti

Hi Matti,

changed my code to

wktLayer.setWellKnownText(wktText);
openLayersMap.addLayer(wktLayer);

from your example and the map appears and no error :slight_smile:

before I did it the other way: addLayer, then setWellKnownText()

now I can play around with WKT this weekend and see if all works well. I’ll let you know

thx again

ekke