From: Edwin C. <com...@gm...> - 2010-10-13 13:24:41
|
Hi Philipp, Aha, so I did not understand containsPoint correctly. What we need is three-valued logic, but there is no basic type for that :). One option is to return a String and map the values onto that: true = 'in' false = 'out' 1 = 'edge' That way the containsPoint implementation can just return a String. public static native String containsPoint(JSObject p, JSObject self)/*-{ var out = self.containsPoint(p); if (out === true) {return 'in'} // if out === 1 then if (out) will also run! else if (out===1) {return 'edge'} else {return 'out'} }-*/; Greetings, Edwin On 13 October 2010 14:06, Philipp Verhoeven <phi...@go...> wrote: > Hi there, > > thanks for that. But there is a problem: > your suggested code returns true if var is 1. But if var is true it returns > false... > > The containsPoint()-method returns 1, if the point is on an edge. > It returns true, if the point is inside and it returns false, if the point > is outside. > > With my not existing JS skills the solution was the following: > > public static native boolean containsPoint(JSObject p, JSObject self)/*-{ > var out = self.containsPoint(p); > if (out) {return true} > else if (out===1) {return true} > else {return false} > }-*/; > > Cheers and thanks, > Philipp > > > 2010/10/12 Edwin Commandeur <com...@gm...> >> >> Hi Phillip, >> >> The containsPoint function in OL is a bit silly in that it returns 1 >> for true and false for false :). I would say we return a boolean. >> >> Try adding this to Polygon >> >> public boolean containsPoint(Point p){ >> PolygonImpl.containsPoint(p.getJSObject(), this.getJSObject()); >> } >> >> and this to PolygonImpl >> >> public static native boolean containsPoint(JSObject p, JSObject self)/*-{ >> var out = self.containsPoint(p); >> return (out===1)?true:false; >> }-*/; >> >> Greetings, >> Edwin Commandeur >> >> On 12 October 2010 15:47, Philipp Verhoeven >> <phi...@go...> wrote: >> > Greetings, >> > >> > >> > I would like to use the containsPoint method of the Polygon class like >> > it is >> > desribed: >> > >> > http://dev.openlayers.org/docs/files/OpenLayers/Geometry/Polygon-js.html#OpenLayers.Geometry.Polygon.containsPoint >> > >> > The method doesn't seem to be implemented in gwt-openlayers, am I >> > right?! >> > >> > Does anyone know a quick fix to use this method anyway? >> > >> > >> > Thanks and cheers, >> > Philipp >> > >> > >> > ------------------------------------------------------------------------------ >> > Beautiful is writing same markup. Internet Explorer 9 supports >> > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. >> > Spend less time writing and rewriting code and more time creating great >> > experiences on the web. Be a part of the beta today. >> > http://p.sf.net/sfu/beautyoftheweb >> > _______________________________________________ >> > Gwt-openlayers-users mailing list >> > Gwt...@li... >> > https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users >> > >> > > > |