Re: [osmosis-dev] WayKeyFilter

2009-11-19 Thread Peter Körner
 should entities belonging to entity types not being  
 filtered be passed through or thrown away? 

This is how I'd like it from the user perspective

remove all nodes
   osmosis \
--read-xml in.xml \
--exclude node \
--write-xml out.xml

keep only ways
   osmosis \
--read-xml in.xml \
--include way \
--write-xml out.xml

keep only ways and their nodes ( thus removing all nodes not in a way)
   osmosis \
--read-xml in.xml \
--include way-with-nodes \
--write-xml out.xml

keep only highways and their nodes
   osmosis \
--read-xml in.xml \
--include way-with-nodes highway=* \
--write-xml out.xml

keep only trunks and their nodes
   osmosis \
--read-xml in.xml \
--include way-with-nodes highway=trunk \
--write-xml out.xml

keep only countries and islands
   osmosis \
--read-xml in.xml \
--include node place=country place=island \
--write-xml out.xml

keep only nodes but no countries or islands
   osmosis \
--read-xml in.xml \
--include node
--exclude node place=country place=island \
--write-xml out.xml



Some sugar would be if we could have the CSS3 attribute selectors:
http://www.w3.org/TR/css3-selectors/#attribute-representation
http://www.w3.org/TR/css3-selectors/#attribute-substrings
e.g.

   --include node place=city is_in~=europe
which would include all cities that got europe in their is_in list

or

   --include way-with-nodes highway^=trunk
which would include all ways with a highway-tag that starts with trunk


Peter

___
osmosis-dev mailing list
osmosis-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/osmosis-dev


Re: [osmosis-dev] WayKeyFilter

2009-11-19 Thread Brett Henderson
On Thu, Nov 19, 2009 at 11:27 PM, Andrew Byrd and...@fastmail.net wrote:

 On 19 Nov 2009, at 07:30, Brett Henderson wrote:
 
  Can you please update the wiki detailed usage page to reflect the
  new task?
  http://wiki.openstreetmap.org/wiki/Osmosis/DetailedUsage

 Done. I noted that it is currently only in svn.


Great, thanks.



  On this note, if anybody is keen Osmosis could really do with
  somebody to take on creating a consistent set of filtering tasks for
  all entity types (at a minimum it appears that relations are missing
  from the existing set of tasks).  I'm not sure what the requirements
  would be and I don't do any filtering myself so don't have much
  experience with it.  I think all existing tasks have a bug at the
  moment where they don't handle ',' characters in the key names which
  probably should also be fixed.

 It should be rather simple to extend the existing filter set to
 relations. I have little experience with OSM/Osmosis myself, yet the
 task architecture was easy to understand. One thing needs to be
 clarified, though: should entities belonging to entity types not being
 filtered be passed through or thrown away? Currently, the node filters
 pass only nodes through, while the way filters pass non-way entities
 through unchanged. I see the practical reason for this, but it's not
 consistent. Maybe there should be an option to choose between behaviors.


I think filters should behave consistently rather than having each entity
type treated differently for a particular use case convenience.  Usually I
try to avoid changing existing behaviour, but only if there's a reasonable
alternative.  If the current filters are inconsistent I think we should
change them.  If we are going to break existing behaviour though I think we
should attempt to make all the breaking changes at once rather than
dribbling them in over a longer period.

But I didn't write the original tasks and haven't used them so I'm not well
placed to decide how they should work.



 According to the wiki, a tag is a Key-Value pair of Unicode strings
 of up to 255 characters (full Unicode characters, not bytes).  There
 is no mention of excluded list separator characters, so if it was
 changed from comma to something else, there would still be a bug and
 it would cause havoc with people used to using commas.  One reasonable
 solution is some kind of escape character (backslash?) for non-
 splitting commas that are in the key name.


Yep, I think we'd have to escape the separating character if it is included
in the key.  Given the rarity of something like a ',' in a tag name, I don't
think there's an issue with requiring users to escape it when it does occur.



 It would also be helpful to have a switch to invert filter logic from
 accept to remove, e.g. so you can accept everything with a highway tag
 then remove everything that has the highway=motorway value. This would
 make for a cleaner operation (and command line) than trying to make an
 exhaustive list of every key-value you want to keep.

 It would be nice to have comments from users and developers about how
 the filter set should be designed, and once that's clear I think the
 new tasks would show up, since they are useful to a lot of people, but
 not major undertakings.


I'm gonna take a back seat on this one :-)  If you have some time to gather
some requirements, tidy up the existing tasks, and add new features then go
for it.

Don't feel the need to get full consensus before you do something.
Obviously it's a good idea to gather ideas, but feel free to come up with
what you think works well, implement it, and then get feedback.

Brett
___
osmosis-dev mailing list
osmosis-dev@openstreetmap.org
http://lists.openstreetmap.org/listinfo/osmosis-dev