[OpenLayers-Dev] Advice on best way to extend a OL class.

Eric Lemoine eric.lemoine at camptocamp.com
Sun Nov 13 17:06:26 EST 2011


On Sunday, November 13, 2011, Phil Scadden <p.scadden at gns.cri.nz> wrote:
>
>>   The "Strategy Cluster Extended" would be a good class extending
>> example :
>>
>> http://openlayers.org/dev/examples/strategy-cluster-extended.html
> Thanks for that. Still got a javascript issue though.
>
> Suppose I extend linearRing with the swapXY method - call it linearRingEx.
>
> The code calling context though is:
>                             } else if (filter.type ===
> OpenLayers.Filter.Spatial.INTERSECTS) {
>                                 var geom = filter.value;
>                                 transformGeometry(geom);
>                                 geom.components[0].swapXY();
>                                 params.cql_filter = 'INTERSECTS(SHAPE,'
> + geom.toString() + ')';
>
> To call the swapXY method, I need to somehow cast the geom object (a
> superclass) so that the linearRing descendent is of linearRingEx. I am
> struggling to see how to do this in JS.


Why can't you just have a swapXY function that takes a LinearRing as its
1st argument and modifies it in place? Sorry if I'm not understanding your
issue.

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20111113/a89975aa/attachment.html


More information about the Dev mailing list