From: Edwin C. <com...@gm...> - 2009-03-10 07:21:16
|
Hi Brendan, The read methods are a bit trickier than the write methods of Format. I hadn't looked into how to implement them. What I see if I again look at the vector-formats example is that the GML takest the gmlOptions with featureType and featureNS for reading and writing, so that could be the heart of the problem. As far as I can see, a difficulty with implementing read methods for VectorFormat is that when you have for example 3 different polygons these can be 3 different features, or 1 feature with a composite geometry. I am not sure how the different formats solve this and if they solve this uniformly, but I think that GWT-OpenLayers should solve this uniformly. Yesterday, I finally got round to making a start with writing test cases for GWT-OpenLayers (2 and a suite to run them both :-)), which should make it possible to work on the Formats test driven. Greetings, Edwin P.S. I still need to see how the get the test cases and showcase under version control. For the test cases I created a separate module, because (a) GWT-OpenLayers still compiles against GWT 1.4 and running a test suite requires GWT 1.5 (b) that separate module could than point at the OpenLayers script in the module xml, which is necessary for running the tests. 2009/3/9 Brendan Grady <bre...@gm...> > Thanks Edwin - I added that to the impl, and it started working - pretty > strange that the openlayers api claims that options is not required in the > constructor, yet there are two properties, featureType and featureNS, that > are marked as required. > ( > http://dev.openlayers.org/releases/OpenLayers-2.7/doc/apidocs/files/OpenLayers/Format/GML/v3-js.html) > > Any ideas about how to implement the read method in VectorFeature? I > uncommented what you had so that the body of the method now looks something > like this: > > return VectorFeature.narrowToVectorFeature( > FormatImpl.read(getJSObject(), input) ); > > No errors, but the feature failed to plot when I added it via > Vector.addFeature() > > I then saw that the openlayers api says that GML.read() is returning an > Array of Vectors, so I tried to convert the JSObject that comes back from > FormatImpl.read() into a JSObject[]. See snippets below. > > In VectorFormat.read(): > > JSObject arrayObject = FormatImpl.read(getJSObject(), input); > > JSObject[] array = ElementHelper.toArray(arrayObject); > VectorFeature[] features = new VectorFeature[array.length]; > for( int i = 0; i < array.length ; i++){ > features[i] = VectorFeature.narrowToVectorFeature(array[i]); > } > > In ElementHelper: > > public static JSObject[] toArray(JSObject array) { > int length = getArraySize(array); > JSObject[] recs = new JSObject[length]; > for (int i = 0; i < length; i++) { > recs[i] = getValueFromJavaScriptObjectArray(array, i); > } > return recs; > } > > public static native JSObject getValueFromJavaScriptObjectArray( > JSObject elem, int i) /*-{ > return elem[i]; > }-*/; > > > Again, no errors, but the feature failed to plot. > > Again, thanks for any tips, > Brendan > > > > On Fri, Mar 6, 2009 at 4:39 AM, Edwin Commandeur < > com...@gm...> wrote: > >> Hi Brendan, >> >> As far as I can see the problem is with the GML constructor. The >> constructor needs an options object, even if it that options object is >> empty. I added an empty options object to the GMLImpl create method. >> >> Possibly it needs more. If I look at the vector-formats example than it >> might be necessary to change: >> >> public static native JSObject create() >> /*-{ >> return new $wnd.OpenLayers.Format.GML.v3({}); >> }-*/; >> >> to >> >> public static native JSObject create(String type, String namespace) >> /*-{ >> return new $wnd.OpenLayers.Format.GML.v3({ featureType : type, >> featureNS: namespace }); >> }-*/; >> >> >> Greetings, >> >> Edwin >> >> 2009/3/5 Brendan Grady <bre...@gm...> >> >>> Hi Edwin, >>> >>> An updated patch to include the DragFeature Control. >>> >>> I figured out the weirdness with KML, and that one was my fault. It >>> appears when I added the KML to the popup, that it lost everything that had >>> special characters in it. Makes sense because I think the Popup is supposed >>> to be just for HTML. >>> >>> However, I am pretty stumped with GML. Everything in the code looks like >>> it should work, but the call to the empty constructor fails. Looking at the >>> Openlayer api, any options should be optional. >>> >>> Some more debug info: >>> >>> - new GML() fails outright with a an exception in the GWT shell output: >>> >>> GWTShell: >>> [java] Uncaught JavaScript exception >>> [com.google.gwt.core.client.JavaScriptException: (TypeError): Object >>> expected >>> [java] number: -2146823281 >>> [java] description: Object expected >>> [java] at >>> com.eg.gwt.openLayers.client.format.GML2Impl.create(Native Method) >>> [java] at >>> com.eg.gwt.openLayers.client.format.GML2.<init>(GML2.java:21) >>> >>> >>> At the moment, serializing and deserializing in GML is my most pressing >>> feature. Hopefully, I have a breakthough before my prototype demo tomorrow. >>> >>> If you have any insight/ideas into deserialization, I would be happy to >>> try to implement them. >>> >>> Thanks Again, >>> Brendan >>> >>> >>> >>> >>> On Thu, Mar 5, 2009 at 2:35 PM, Edwin Commandeur < >>> com...@gm...> wrote: >>> >>>> Hi Brendan, >>>> >>>> Thanks for the patch. I will take look at it and already commit the css >>>> to the trunk first thing tommorow morning. >>>> >>>> If WKT works, than I'm pretty sure that KML needs some additional >>>> options that can't be specified yet. I added a Tracker on SF to track >>>> Milestone issues, which should list all the issues to be fixed for release >>>> 0.4 and getting the KML Format fully working will definitely be on the list. >>>> >>>> Greetings and thanks for all your efforts, >>>> Edwin >>>> >>>> 2009/3/5 Brendan Grady <bre...@gm...> >>>> >>>> Thanks again for the response. I really appreciate your time. >>>>> >>>>> I'm sure you are swamped with other things, so I put together a patch >>>>> for adding controls to the EditControlPanel. If you think it is ok, feel >>>>> free to add it to the trunk. First time working with JSNI, so if it doesn't >>>>> follow standards, feel free to scrap it. >>>>> >>>>> The following css needs to be added to your applications css: >>>>> >>>>> .olControlEditingToolbar { >>>>> width: 400px!important; >>>>> } >>>>> .olControlEditingToolbar .olControlSelectFeatureItemActive { >>>>> background-image: url("img/select_feature_on.png"); >>>>> background-repeat: no-repeat; >>>>> } >>>>> .olControlEditingToolbar .olControlSelectFeatureItemInactive { >>>>> background-image: url("img/select_feature_off.png"); >>>>> background-repeat: no-repeat; >>>>> } >>>>> .olControlEditingToolbar .olControlModifyFeatureItemActive { >>>>> background-image: url("img/move_vertex_on.png"); >>>>> background-repeat: no-repeat; >>>>> } >>>>> .olControlEditingToolbar .olControlModifyFeatureItemInactive { >>>>> background-image: url("img/move_vertex_off.png"); >>>>> background-repeat: no-repeat; >>>>> } >>>>> .olControlEditingToolbar .olControlDragFeatureItemActive { >>>>> background-image: >>>>> url("openlayers/theme/default/img/move_feature_on.png"); >>>>> background-repeat: no-repeat; >>>>> } >>>>> .olControlEditingToolbar .olControlDragFeatureItemInactive { >>>>> background-image: >>>>> url("openlayers/theme/default/img/move_feature_off.png"); >>>>> background-repeat: no-repeat; >>>>> } >>>>> >>>>> If you can't find the images, I can provide those too. As a zip maybe? >>>>> >>>>> I'm also going to take a look at the GML2,3 / KML >>>>> serializer/deserializer. Those seem to be broken right now, though WKT >>>>> serialize does seem to work, so I'll use that as a guideline. >>>>> >>>>> Brendan >>>>> >>>>> >>>>> >>>>> On Thu, Mar 5, 2009 at 8:53 AM, Brendan Grady <bre...@gm... >>>>> > wrote: >>>>> >>>>>> Hi Edwin - >>>>>> >>>>>> The SelectFeature appears to be working perfectly. Thanks! >>>>>> >>>>>> Implementing the editing features that are in >>>>>> http://crschmidt.net/mapping/wpserverdemo/ would make for a very >>>>>> powerful toolset. I would be happy to test out whatever you have. >>>>>> >>>>>> As an aside, this is how I tested out the Select Feauture: >>>>>> >>>>>> SelectFeatureOptions options = new SelectFeatureOptions(); >>>>>> options.onSelect( new SelectFeature.SelectFeatureListener(){ >>>>>> >>>>>> public void onFeatureSelected(JSObject vectorFeature) { >>>>>> VectorFeature overlay = >>>>>> VectorFeature.narrowToVectorFeature(vectorFeature); >>>>>> popup = new AnchoredBubble("vector-info", >>>>>> new LonLat(0,0), >>>>>> new Size(300, 400), >>>>>> "<p>" + new KML().write(overlay) + "</p>", >>>>>> new Icon("", new Size(0, 0), new Pixel(0, 0)), >>>>>> true); >>>>>> map.addPopup(popup); >>>>>> } >>>>>> >>>>>> }); >>>>>> >>>>>> For some reason though, the info that popped up is not KML. It looks >>>>>> more like this: >>>>>> >>>>>> OpenLayers exportExported on Thu Mar 5 08:49:56 >>>>>> EST2009OpenLayers.Feature.Vector_262No description available-0.0703125, >>>>>> 2.4609375 -0.703125,-20.390625 ... >>>>>> >>>>>> Am I using the KML exporter incorrectly? >>>>>> >>>>>> Thanks again, >>>>>> >>>>>> Brendan >>>>>> >>>>>> >>>>>> >>>>>> On Thu, Mar 5, 2009 at 5:43 AM, Edwin Commandeur < >>>>>> com...@gm...> wrote: >>>>>> >>>>>>> Hi there, >>>>>>> >>>>>>> Selecting features happens with a control in OpenLayers. I saw in the >>>>>>> GWT-OpenLayers codebase that we are not yet wrapping the SelectFeature >>>>>>> control. By default the SelectFeature selects features on click and you can >>>>>>> pass it options to select on hover. >>>>>>> >>>>>>> So: >>>>>>> (1) we need to add support for the select feature control => ADDED 5 >>>>>>> min ago >>>>>>> >>>>>>> I added a wrapper for SelectFeature, but did not thoroughly test >>>>>>> it... Maybe you can try it out. >>>>>>> >>>>>>> One caveat: The onSelect and onUnselect callback methods do not hook >>>>>>> in with the broader OpenLayers event system. By the latter I mean that for >>>>>>> example Vector (a vector layer object) has an Event object to register and >>>>>>> unregister events, while the onSelect and onUnselect are just callback >>>>>>> methods of the Control. This is why I added the Listener interfaces to the >>>>>>> Control itself and this is why the methods onSelectFeature and >>>>>>> onUnselectFeature return a JSObject which is a VectorFeature that you have >>>>>>> to narrow to a VectorFeature yourself inside the method e.g. >>>>>>> new SelectFeatureListener(){ >>>>>>> public void onSelectFeature(JSObject vectorFeature) { >>>>>>> VectorFeature vf = >>>>>>> VectorFeature.narrowToVectorFeature(vectorFeature); >>>>>>> } >>>>>>> >>>>>>> (2) you then need to add a button to activate the SelectFeature >>>>>>> control (and deactivate the other editing controls). >>>>>>> >>>>>>> Point (2) could be realised in two ways: (a) you should create your >>>>>>> own editing toolbar using GWT (b) we could support adding controls to the >>>>>>> Editing Toolbar. Option 2b is not yet in OpenLayers, but would not be very >>>>>>> difficult to support this in GWT-OpenLayers. I guess that most people want >>>>>>> an editing toolbar like this one: >>>>>>> >>>>>>> http://crschmidt.net/mapping/wpserverdemo/ >>>>>>> >>>>>>> I will look into point 2b shortly, but cannot promise to have >>>>>>> anything ready overnight. >>>>>>> >>>>>>> Greetings, >>>>>>> Edwin >>>>>>> >>>>>>> 2009/3/4 Brendan Grady <bre...@gm...> >>>>>>> >>>>>>>> Hello, >>>>>>>> >>>>>>>> >>>>>>>> New user to gwt-openlayers. >>>>>>>> >>>>>>>> Does anyone have an example of adding a "select" listener to a >>>>>>>> Vector layer? I am adding vectors using the Editing Toolbar. >>>>>>>> >>>>>>>> In openlayers, I would add something like the following: >>>>>>>> >>>>>>>> selectControl = new OpenLayers.Control.SelectFeature(overlayLayer, >>>>>>>> {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}); >>>>>>>> >>>>>>>> >>>>>>>> I tried the following, but I think I need to add something else to >>>>>>>> the map to make the layer "selectable" as it does not seem to register that >>>>>>>> I am over a selectable vector: >>>>>>>> >>>>>>>> <snip> >>>>>>>> Vector overlayLayer = new Vector("Overlay Creation Layer"); >>>>>>>> map.addLayer(overlayLayer); >>>>>>>> map.addControl(new EditingToolbar(overlayLayer)); >>>>>>>> >>>>>>>> overlayLayer.addVectorFeatureSelectedListener( new >>>>>>>> VectorFeatureSelectedListener(){ >>>>>>>> >>>>>>>> public void onFeatureSelected(Vector source, >>>>>>>> FeatureSelectedEvent eventObject) { >>>>>>>> VectorFeature overlay = eventObject.getFeature(); >>>>>>>> popup = new AnchoredBubble("vector-info", >>>>>>>> new LonLat(0,0), >>>>>>>> new Size(300, 400), >>>>>>>> "<p>" + new KML().write(overlay) + "</p>", >>>>>>>> new Icon("", new Size(0, 0), new Pixel(0, >>>>>>>> 0)), >>>>>>>> true); >>>>>>>> map.addPopup(popup); >>>>>>>> } >>>>>>>> >>>>>>>> }); >>>>>>>> </snip> >>>>>>>> >>>>>>>> Any suggestions? >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Brendan >>>>>>>> >>>>>>>> >>>>>>>> ------------------------------------------------------------------------------ >>>>>>>> Open Source Business Conference (OSBC), March 24-25, 2009, San >>>>>>>> Francisco, CA >>>>>>>> -OSBC tackles the biggest issue in open source: Open Sourcing the >>>>>>>> Enterprise >>>>>>>> -Strategies to boost innovation and cut costs with open source >>>>>>>> participation >>>>>>>> -Receive a $600 discount off the registration fee with the source >>>>>>>> code: SFAD >>>>>>>> http://p.sf.net/sfu/XcvMzF8H >>>>>>>> _______________________________________________ >>>>>>>> Gwt-openlayers-users mailing list >>>>>>>> Gwt...@li... >>>>>>>> https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> Open Source Business Conference (OSBC), March 24-25, 2009, San >>>>>>> Francisco, CA >>>>>>> -OSBC tackles the biggest issue in open source: Open Sourcing the >>>>>>> Enterprise >>>>>>> -Strategies to boost innovation and cut costs with open source >>>>>>> participation >>>>>>> -Receive a $600 discount off the registration fee with the source >>>>>>> code: SFAD >>>>>>> http://p.sf.net/sfu/XcvMzF8H >>>>>>> _______________________________________________ >>>>>>> Gwt-openlayers-users mailing list >>>>>>> Gwt...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> > |