Hello everyone.
I have been looking at the filtering on Mapstraction and realized that it does
not allow for sub-filters.
I have modified the applyFilter function to accommodate sub filters.
for example if I wanted to filter all houses that are blue and green and also
all warehouses irrespective of color
now I can use
map.addFilter(''Type'', ''eq'', { pFilter:
"House",
sFilter: [''Color'',
''eq'', ''Blue'']
});
map.addFilter(''Type'',
''eq'', { pFilter: "House",
sFilter: [''Color'',
''eq'', ''Green'']
});
map.addFilter(''Type'',
''eq'', "Warehouse");
map.doFilter();
I would have loved to be able to add multiple arrays of sub-filters
for example
map.addFilter(''field'', ''operator'', {
pFilter: "value",
sFilter: [[''field'',
''operator'',
''value''],[''field'',
''operator'',
''value''],[''field'',
''operator'', ''value'']]
});
If anyone has an idea on the implementation please do contribute.
This is the function as I have it right now
Mapstraction.prototype.applyFilter = function(o, f) {
var vis = true;
switch (f[1]) {
case ''ge'':
if (typeof f[2] == ''object'') {
if (o.getAttribute(f[0]) < f[2].pFilter) {
vis = this.applyFilter(o, f[2].sFilter);
}
} else {
if (o.getAttribute(f[0]) < f[2]) {
vis = false;
}
}
break;
case ''le'':
if (typeof f[2] == ''object'') {
if (o.getAttribute(f[0]) > f[2].pFilter) {
vis = this.applyFilter(o, f[2].sFilter);
}
} else {
if (o.getAttribute(f[0]) > f[2]) {
vis = false;
}
}
break;
case ''eq'':
if (typeof f[2] == ''object'') {
if (o.getAttribute(f[0]) == f[2].pFilter) {
vis = this.applyFilter(o, f[2].sFilter);
}
} else {
if (o.getAttribute(f[0]) == f[2]) {
vis = false;
}
}
break;
}
return vis;
};
_________________________________________________________________
Bing brings you maps, menus, and reviews organized in one place.
http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20091130/e0ad15ca/attachment.htm>
I forgot to include all the changes for the other methods for
toggleFilter()
removeFilter()
The patch also contains the addGeoJSON() as submited by Callum Macdonald
From: joram5911 at hotmail.com
To: mapstraction at lists.mapstraction.com
Date: Mon, 30 Nov 2009 22:48:04 +0000
Subject: [Mapstraction] Specifying sub-filters
Hello everyone.
I have been looking at the filtering on Mapstraction and realized that it does
not allow for sub-filters.
I have modified the applyFilter function to accommodate sub filters.
for example if I wanted to filter all houses that are blue and green and also
all warehouses irrespective of color
now I can use
map.addFilter(''Type'', ''eq'', { pFilter:
"House",
sFilter: [''Color'',
''eq'', ''Blue'']
});
map.addFilter(''Type'',
''eq'', { pFilter: "House",
sFilter: [''Color'',
''eq'', ''Green'']
});
map.addFilter(''Type'',
''eq'', "Warehouse");
map.doFilter();
I would have loved to be able to add multiple arrays of sub-filters
for example
map.addFilter(''field'', ''operator'', {
pFilter: "value",
sFilter: [[''field'',
''operator'',
''value''],[''field'',
''operator'',
''value''],[''field'',
''operator'', ''value'']]
});
If anyone has an idea on the implementation please do contribute.
This is the function as I have it right now
Mapstraction.prototype.applyFilter = function(o, f) {
var vis = true;
switch (f[1]) {
case ''ge'':
if (typeof f[2] == ''object'') {
if (o.getAttribute(f[0]) < f[2].pFilter) {
vis = this.applyFilter(o, f[2].sFilter);
}
} else {
if (o.getAttribute(f[0]) < f[2]) {
vis = false;
}
}
break;
case ''le'':
if (typeof f[2] == ''object'') {
if (o.getAttribute(f[0]) > f[2].pFilter) {
vis = this.applyFilter(o, f[2].sFilter);
}
} else {
if (o.getAttribute(f[0]) > f[2]) {
vis = false;
}
}
break;
case ''eq'':
if (typeof f[2] == ''object'') {
if (o.getAttribute(f[0]) == f[2].pFilter) {
vis = this.applyFilter(o, f[2].sFilter);
}
} else {
if (o.getAttribute(f[0]) == f[2]) {
vis = false;
}
}
break;
}
return vis;
};
Bing brings you maps, menus, and reviews organized in one place. Try it now.
_________________________________________________________________
Chat with Messenger straight from your Hotmail inbox.
http://www.microsoft.com/windows/windowslive/hotmail_bl1/hotmail_bl1.aspx?ocid=PID23879::T:WLMTAGL:ON:WL:en-ww:WM_IMHM_4:092009
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20091204/a67c2f7d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mxn.core.patch
Type: application/octet-stream
Size: 108698 bytes
Desc: not available
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20091204/a67c2f7d/attachment-0001.obj>
jokie36688 Tom wrote:> Hello everyone. > > I have been looking at the filtering on Mapstraction and realized that > it does not allow for sub-filters. > I have modified the applyFilter function to accommodate sub filters. >Very cool. Anyone have an idea about how to chain these together into a single call? Would want to be able to specify the operator on these combined sub-filters (OR, AND) And as I write this I see that I just got a request for your post to be moderated with the actual patch (which is what I was going to ask for ;) However, looks like it''s showing all the changes from Tabs to Spaces. Can you do a patch while ignoring whitespace changes? And also can you add in some docs in the code too? Thanks! Andrew> for example if I wanted to filter all houses that are blue and green > and also all warehouses irrespective of color > now I can use > > map.addFilter(''Type'', ''eq'', { pFilter: "House", > sFilter: [''Color'', ''eq'', ''Blue''] > }); > map.addFilter(''Type'', ''eq'', { pFilter: "House", > sFilter: [''Color'', ''eq'', ''Green''] > }); > map.addFilter(''Type'', ''eq'', "Warehouse"); > map.doFilter(); > > I would have loved to be able to add multiple arrays of sub-filters > for example > > map.addFilter(''field'', ''operator'', { pFilter: "value", > sFilter: [[''field'', ''operator'', > ''value''],[''field'', ''operator'', ''value''],[''field'', ''operator'', ''value'']] > }); > > If anyone has an idea on the implementation please do contribute. > > This is the function as I have it right now > > Mapstraction.prototype.applyFilter = function(o, f) { > var vis = true; > switch (f[1]) { > case ''ge'': > > if (typeof f[2] == ''object'') { > if (o.getAttribute(f[0]) < f[2].pFilter) { > vis = this.applyFilter(o, f[2].sFilter); > } > } else { > if (o.getAttribute(f[0]) < f[2]) { > vis = false; > } > } > break; > case ''le'': > > if (typeof f[2] == ''object'') { > if (o.getAttribute(f[0]) > f[2].pFilter) { > vis = this.applyFilter(o, f[2].sFilter); > } > } else { > if (o.getAttribute(f[0]) > f[2]) { > vis = false; > } > } > break; > case ''eq'': > if (typeof f[2] == ''object'') { > if (o.getAttribute(f[0]) == f[2].pFilter) { > vis = this.applyFilter(o, f[2].sFilter); > } > } else { > if (o.getAttribute(f[0]) == f[2]) { > vis = false; > } > } > break; > } > > return vis; > }; > > ------------------------------------------------------------------------ > Bing brings you maps, menus, and reviews organized in one place. Try > it now. > <http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1> > > ------------------------------------------------------------------------ > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com >-- Andrew Turner m: 248.982.3609 e: andrew at highearthorbit.com t: @ajturner b: http://highearthorbit.com w: http://geocommons.com Introduction to Neogeography - http://oreilly.com/catalog/neogeography -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20091213/c1ec405c/attachment.htm>
I''d like to see addFilter just take a function that is passed either
the
marker or its data object and has to return a boolean. That way you can
filter by anything e.g.
map.addFilter(function(data) { return data.Type == "House"; });
map.addFilter(function(data) {
return data.Type == "House" && (data.Color ==
"Blue" || data.Color ="Green");
});
Derek
2009/12/13 Andrew Turner <ajturner at highearthorbit.com>
> jokie36688 Tom wrote:
>
> Hello everyone.
>
> I have been looking at the filtering on Mapstraction and realized that it
> does not allow for sub-filters.
> I have modified the applyFilter function to accommodate sub filters.
>
> Very cool.
>
> Anyone have an idea about how to chain these together into a single call?
> Would want to be able to specify the operator on these combined sub-filters
> (OR, AND)
>
> And as I write this I see that I just got a request for your post to be
> moderated with the actual patch (which is what I was going to ask for ;)
> However, looks like it''s showing all the changes from Tabs to
Spaces. Can
> you do a patch while ignoring whitespace changes? And also can you add in
> some docs in the code too?
>
> Thanks!
> Andrew
>
>
> for example if I wanted to filter all houses that are blue and green and
> also all warehouses irrespective of color
> now I can use
>
> map.addFilter(''Type'', ''eq'', { pFilter:
"House",
> sFilter: [''Color'',
''eq'', ''Blue'']
> });
> map.addFilter(''Type'',
''eq'', { pFilter: "House",
> sFilter: [''Color'',
''eq'', ''Green'']
> });
> map.addFilter(''Type'',
''eq'', "Warehouse");
> map.doFilter();
>
> I would have loved to be able to add multiple arrays of sub-filters
> for example
>
> map.addFilter(''field'', ''operator'', {
pFilter: "value",
> sFilter: [[''field'',
''operator'',
''value''],[''field'',
> ''operator'',
''value''],[''field'',
''operator'', ''value'']]
> });
>
> If anyone has an idea on the implementation please do contribute.
>
> This is the function as I have it right now
>
> Mapstraction.prototype.applyFilter = function(o, f) {
> var vis = true;
> switch (f[1]) {
> case ''ge'':
>
> if (typeof f[2] == ''object'') {
> if (o.getAttribute(f[0]) < f[2].pFilter) {
> vis = this.applyFilter(o, f[2].sFilter);
> }
> } else {
> if (o.getAttribute(f[0]) < f[2]) {
> vis = false;
> }
> }
> break;
> case ''le'':
>
> if (typeof f[2] == ''object'') {
> if (o.getAttribute(f[0]) > f[2].pFilter) {
> vis = this.applyFilter(o, f[2].sFilter);
> }
> } else {
> if (o.getAttribute(f[0]) > f[2]) {
> vis = false;
> }
> }
> break;
> case ''eq'':
> if (typeof f[2] == ''object'') {
> if (o.getAttribute(f[0]) == f[2].pFilter) {
> vis = this.applyFilter(o, f[2].sFilter);
> }
> } else {
> if (o.getAttribute(f[0]) == f[2]) {
> vis = false;
> }
> }
> break;
> }
>
> return vis;
> };
>
> ------------------------------
> Bing brings you maps, menus, and reviews organized in one place. Try it
>
now.<http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1>
>
> ------------------------------
>
> _______________________________________________
> Mapstraction mailing listMapstraction at
lists.mapstraction.comhttp://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com
>
>
>
> --
> Andrew Turner
> m: 248.982.3609 e: andrew at highearthorbit.com t: @ajturner
> b: http://highearthorbit.com w: http://geocommons.com
>
> Introduction to Neogeography - http://oreilly.com/catalog/neogeography
>
>
> _______________________________________________
> Mapstraction mailing list
> Mapstraction at lists.mapstraction.com
> http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com
>
>
--
Derek Fowler
m. +44 (0) 7966 512 369
e. dezfowler at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20091215/25c834d0/attachment.htm>