Hello everybody,

first of all, thank you all for developing Osmosis! :)

I currently have some issues with the compressionMethod parameter in the XML tasks. This is just a minor annoyance but nevertheless:

The compressionMethod parameter of the --[fast]-read-xml task is currently handled somewhat differently than most other parameters in Osmosis. CompressionMethod has three official values (none, gzip, bzip2), but actually there is a fourth option (autodetect) which can only be specified implicitly by omitting compressionMethod altogether.

Although this is documented in the wiki, it creates problems for people who build tools around Osmosis which read and/or generate Osmosis command lines automatically, and even for a human user, this is another special case which you need to think of (no other parameter in any task works this way).

This can easily be fixed by creating an explicit fourth value (say, "auto") for compressionMethod, and making it the default value. This change doesn't break old scripts and streamlines the parameters for new ones. The attached patch against current trunk does this (and the trunk still passes all unit tests with the patch applied).

It would be cool if you could integrate this into the next version of Osmosis. If you have any questions or if the patch needs some improvement, I'll be here on the mailing list :).

Best regards
Igor
Index: xml/src/org/openstreetmap/osmosis/xml/common/XmlTaskManagerFactory.java
===================================================================
--- xml/src/org/openstreetmap/osmosis/xml/common/XmlTaskManagerFactory.java     
(Revision 25225)
+++ xml/src/org/openstreetmap/osmosis/xml/common/XmlTaskManagerFactory.java     
(Arbeitskopie)
@@ -33,27 +33,21 @@
                        TaskConfiguration taskConfig, String fileName) {
                CompressionMethod result;
                
-               if (doesArgumentExist(taskConfig, ARG_COMPRESSION_METHOD)) {
-                       String rawValue;
+               String rawValue = getStringArgument(taskConfig, 
ARG_COMPRESSION_METHOD, "auto").toLowerCase();
                        
-                       rawValue = getStringArgument(taskConfig, 
ARG_COMPRESSION_METHOD).toLowerCase();
-                       
-                       if ("none".equals(rawValue)) {
-                               result = CompressionMethod.None;
-                       } else if ("gzip".equals(rawValue)) {
-                               result = CompressionMethod.GZip;
-                       } else if ("bzip2".equals(rawValue)) {
-                               result = CompressionMethod.BZip2;
-                       } else {
-                               throw new OsmosisRuntimeException(
-                                       "Argument " + ARG_COMPRESSION_METHOD + 
" for task " + taskConfig.getId()
-                                       + " must be one of none, gzip, or 
bzip2.");
-                       }
-                       
-               } else {
+               if ("none".equals(rawValue)) {
+                       result = CompressionMethod.None;
+               } else if ("gzip".equals(rawValue)) {
+                       result = CompressionMethod.GZip;
+               } else if ("bzip2".equals(rawValue)) {
+                       result = CompressionMethod.BZip2;
+               } else if ("auto".equals(rawValue)) {
                        result = new 
CompressionMethodDeriver().deriveCompressionMethod(fileName);
-               }
-               
+               } else {
+                       throw new OsmosisRuntimeException(
+                               "Argument " + ARG_COMPRESSION_METHOD + " for 
task " + taskConfig.getId()
+                               + " must be one of none, gzip, bzip2 or auto.");
+               }               
                return result;
        }
        
_______________________________________________
osmosis-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/osmosis-dev

Reply via email to