Good stuff.

I'll scout around and see if there are any other utilities lying around 
which could be added to the code base.

M

Sunburned Surveyor wrote:
> I commited the IOUtil class contributed by Martin to the OpenJUMP SVN.
> The class can be found in the org.openjump.core.apitools package. I
> changed the name of the class from IOUtil to IOTools to match the
> other class names in the package.
>
> Please let me know if there are any questions or problems.
>
> Thanks again for the contribution Martin.
>
> Landon
>
> On Dec 12, 2007 7:13 AM, Sunburned Surveyor
> <[EMAIL PROTECTED]> wrote:
>   
>> I think org.openjump.core.apitools will work. I'll make the addition
>> today after work.
>>
>> Landon
>>
>>
>> On Dec 12, 2007 3:22 AM, Stefan Steiniger <[EMAIL PROTECTED]> wrote:
>>     
>>> no problem.. I would have added the util tools myself too.
>>>
>>> I suggest to place the code into the following package:
>>> - org.openjump.core.apitools
>>>
>>> the alternative would be:
>>> - org.openjump.io
>>>
>>> Not sure which one is better.
>>> Any other thoughts?
>>>
>>> @Sunburned: I could do the checkin as well - if you want.
>>>
>>> stefan
>>>
>>> Sunburned Surveyor schrieb:
>>>
>>>       
>>>> Thanks very much for posting the code Martin. I'll have to see if I
>>>> can't get this into the SVN for OpenJUMP. Do any of the developers see
>>>> a problem with this?
>>>>
>>>> The Sunburned Surveyor
>>>>
>>>> On Dec 11, 2007 4:28 PM, Martin Davis <[EMAIL PROTECTED]> wrote:
>>>>         
>>>>> I have used the core JUMP API in numerous projects, primarily for easily
>>>>> modelling features (spatial + attributes) and having convenient IO
>>>>> (especially for shapefiles!)
>>>>>
>>>>> I had the same need for a simple interface to the JUMP IO classes.  I
>>>>> simply wrote a bunch of utility functions to do IO on the various
>>>>> formats that JUMP supports.  The code is attached in case anyone else
>>>>> finds it useful.  (Some of this might actually be in JUMP/OJ - and if it
>>>>> isn't it might be nice to add it)
>>>>>
>>>>> HTH
>>>>>
>>>>>
>>>>> Sunburned Surveyor wrote:
>>>>>           
>>>>>> I'm working on a little tool that creates a grid in which each cell of
>>>>>> the grid is a polygon. You can create the grid with any rectangular
>>>>>> dimensions, specify the number of columns and rows, and also a
>>>>>> rotation. The tool also allows you to create attributes for each cell
>>>>>> based on the row and column number.
>>>>>>
>>>>>> I'm using JTS and OpenJUMP Features inside of the program.
>>>>>>
>>>>>> I'd like to find the easiest way to export the features and geometries
>>>>>> as an ESRI Shapefile. I was hoping there would a single method that I
>>>>>> could simply pass a FeatureCollection and String representing the path
>>>>>> and file name. I think that would be the write method of the
>>>>>> ShapefileWriter class.
>>>>>>
>>>>>> Is this correct? Is there a newer class/method that I should be using?
>>>>>>
>>>>>> I'm really looking for the easiest way to get from a FeatureCollection
>>>>>> to a Shapefile. I want to make sure I'm using the appropriate code.
>>>>>>
>>>>>> Thanks for any help.
>>>>>>
>>>>>> The Sunburned Surveyor
>>>>>>
>>>>>> P.S. - I was just "scratching my own itch" with this tool, but when I
>>>>>> get the tool finished, I'll release it under the GPL. It will be
>>>>>> pluggable, so you can add your own attribute factories or support for
>>>>>> output formats besides Shapefiles.
>>>>>>
>>>>>> Does anyone else know of third-party apps that are using OpenJUMP code
>>>>>> as a library? Just curious...
>>>>>>
>>>>>> -------------------------------------------------------------------------
>>>>>> SF.Net email is sponsored by:
>>>>>> Check out the new SourceForge.net Marketplace.
>>>>>> It's the best place to buy or sell services for
>>>>>> just about anything Open Source.
>>>>>> http://sourceforge.net/services/buy/index.php
>>>>>> _______________________________________________
>>>>>> Jump-pilot-devel mailing list
>>>>>> Jump-pilot-devel@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>>
>>>>>>
>>>>>>             
>>>>> --
>>>>> Martin Davis
>>>>> Senior Technical Architect
>>>>> Refractions Research, Inc.
>>>>> (250) 383-3022
>>>>>
>>>>>
>>>>> package debug;
>>>>>
>>>>> import java.util.Iterator;
>>>>> import java.util.List;
>>>>>
>>>>> import com.vividsolutions.jump.feature.Feature;
>>>>> import com.vividsolutions.jump.feature.FeatureCollection;
>>>>> import com.vividsolutions.jump.io.*;
>>>>>
>>>>> public class IOUtil {
>>>>>
>>>>>   private static String getExtension(String filename)
>>>>>   {
>>>>>     int len = filename.length();
>>>>>     String extension = filename.substring(len - 3, len);
>>>>>     return extension;
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection load(String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     String extension = getExtension(filename);
>>>>>     if (extension.equalsIgnoreCase("SHP"))
>>>>>       return loadShapefile(filename);
>>>>>     if (extension.equalsIgnoreCase("JML"))
>>>>>       return loadJMLFile(filename);
>>>>>     if (extension.equalsIgnoreCase("WKT"))
>>>>>       return loadWKT(filename);
>>>>>     throw new Exception("Unknown file type: " + extension);
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection load(String filename, String 
>>>>> zipFileName)
>>>>>       throws Exception
>>>>>   {
>>>>>     String extension = getExtension(filename);
>>>>>     if (extension.equalsIgnoreCase("SHP"))
>>>>>       return loadShapefile(filename, zipFileName);
>>>>>     throw new Exception("Unknown file type: " + extension);
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection loadJMLFile(String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     JMLReader rdr = new JMLReader();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set("File", filename);
>>>>>     return rdr.read(dp);
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection loadShapefile(String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     ShapefileReader rdr = new ShapefileReader();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set("File", filename);
>>>>>     return rdr.read(dp);
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection loadShapefile(String filename, String 
>>>>> zipFileName)
>>>>>       throws Exception
>>>>>   {
>>>>>     ShapefileReader rdr = new ShapefileReader();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set(ShapefileReader.FILE_PROPERTY_KEY, filename);
>>>>>     if (zipFileName != null)
>>>>>       dp.set(ShapefileReader.COMPRESSED_FILE_PROPERTY_KEY, zipFileName);
>>>>>     return rdr.read(dp);
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection loadFMEGML(String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     FMEGMLReader rdr = new FMEGMLReader();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set("File", filename);
>>>>>     return rdr.read(dp);
>>>>>   }
>>>>>
>>>>>   public static FeatureCollection loadWKT(String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     WKTReader rdr = new WKTReader();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set("File", filename);
>>>>>     FeatureCollection fc = rdr.read(dp);
>>>>>     return fc;
>>>>>   }
>>>>>
>>>>>   public static void save(FeatureCollection fc, String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     String extension = getExtension(filename);
>>>>>     if (extension.equalsIgnoreCase("SHP")) {
>>>>>       saveShapefile(fc, filename);
>>>>>       return;
>>>>>     }
>>>>>     else if (extension.equalsIgnoreCase("JML")) {
>>>>>       saveJMLFile(fc, filename);
>>>>>       return;
>>>>>     }
>>>>>     throw new Exception("Unknown file type: " + extension);
>>>>>   }
>>>>>
>>>>>   public static void saveShapefile(FeatureCollection fc, String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     ShapefileWriter writer = new ShapefileWriter();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set("File", filename);
>>>>>     writer.write(fc, dp);
>>>>>   }
>>>>>   public static void saveJMLFile(FeatureCollection fc, String filename)
>>>>>       throws Exception
>>>>>   {
>>>>>     JMLWriter writer = new JMLWriter();
>>>>>     DriverProperties dp = new DriverProperties();
>>>>>     dp.set("File", filename);
>>>>>     writer.write(fc, dp);
>>>>>   }
>>>>>   public static void print(FeatureCollection fc)
>>>>>   {
>>>>>     List featList = fc.getFeatures();
>>>>>     for (Iterator i = featList.iterator(); i.hasNext(); ) {
>>>>>       Feature f = (Feature) i.next();
>>>>>       System.out.println(f.getGeometry());
>>>>>     }
>>>>>   }
>>>>>
>>>>> }
>>>>> -------------------------------------------------------------------------
>>>>> SF.Net email is sponsored by:
>>>>> Check out the new SourceForge.net Marketplace.
>>>>> It's the best place to buy or sell services for
>>>>> just about anything Open Source.
>>>>> http://sourceforge.net/services/buy/index.php
>>>>> _______________________________________________
>>>>> Jump-pilot-devel mailing list
>>>>> Jump-pilot-devel@lists.sourceforge.net
>>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>>
>>>>>
>>>>>           
>>>> -------------------------------------------------------------------------
>>>> SF.Net email is sponsored by:
>>>> Check out the new SourceForge.net Marketplace.
>>>> It's the best place to buy or sell services for
>>>> just about anything Open Source.
>>>> http://sourceforge.net/services/buy/index.php
>>>> _______________________________________________
>>>> Jump-pilot-devel mailing list
>>>> Jump-pilot-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>>
>>>>
>>>>         
>>> -------------------------------------------------------------------------
>>> SF.Net email is sponsored by:
>>> Check out the new SourceForge.net Marketplace.
>>> It's the best place to buy or sell services for
>>> just about anything Open Source.
>>> http://sourceforge.net/services/buy/index.php
>>> _______________________________________________
>>> Jump-pilot-devel mailing list
>>> Jump-pilot-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>>
>>>       
>
> -------------------------------------------------------------------------
> SF.Net email is sponsored by:
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services
> for just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>   

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to