public class KmlToGeoJSON extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
CLASSNAME
the full classname as a String for convenience.
|
static String |
SYSTEM_FILE_SEPERATOR
A holder for this clients System File Separator.
|
static String |
SYSTEM_LINE_SEPERATOR
A holder for this clients System line termination separator.
|
Constructor and Description |
---|
KmlToGeoJSON()
Empty constructor.
|
Modifier and Type | Method and Description |
---|---|
static SimpleFeatureCollection |
convertKmlFile(File kmlFile)
Takes a kml file and converts its geo features to a GeoTools SimpleFeatureCollection.
|
static void |
convertKmlFilesInDir(File kmlDirFile)
Takes a kml file and converts it to a GeoJSON file holding all the Geo Features
using GeoTools SimpleFeatureCollection.
|
static String |
featuresToString(SimpleFeatureCollection fc)
This Outputs a SimpleFeatureCollection to a GeoJSON String (for easier saving and output).
|
static String |
formatJsonString(String inStr)
Very basic formatter to make a JSON string more readable.
|
static StringBuilder |
jsonIndenter(String s)
Indents/spaces out an JSON result.
|
static void |
main(String[] args)
Class main commandLine entry method.
|
static StringBuilder |
responseXMLIndenter(StringBuilder sb)
Indents/spaces out an XML result.
|
static String |
tokenReplace(String sentence,
String token,
String replacement)
A simple String token replacement routine.
|
static String |
writeStringToFile(String s,
String fileName)
Abstracts the writing of string to a file.
|
static String |
writeStringToFile(String s,
String fileName,
boolean zipCompress)
Abstracts the writing of string to a (zip) file (Zip NOT IMPLEMENTED YET).
|
public static final String SYSTEM_FILE_SEPERATOR
public static final String SYSTEM_LINE_SEPERATOR
public KmlToGeoJSON()
public static String featuresToString(SimpleFeatureCollection fc) throws IOException
fc
- is the feature collection to serialize into a StringIOException
- whenpublic static String tokenReplace(String sentence, String token, String replacement)
sentence
- The String to perform the token replacement ontoken
- the token String to seartch for and replacereplacement
- the tokens replacement valuepublic static String formatJsonString(String inStr)
public static StringBuilder jsonIndenter(String s)
public static StringBuilder responseXMLIndenter(StringBuilder sb)
public static SimpleFeatureCollection convertKmlFile(File kmlFile) throws Exception
featuresToString
method to get a String version of it.kmlFile
- is a File to processException
public static void convertKmlFilesInDir(File kmlDirFile) throws Exception
convertKmlFile
to do the actual file processing.kmlDirFile
- is a directory File to recursivly processException
public static String writeStringToFile(String s, String fileName)
s
- is the String to writeoutfileName
- is the file name of the file to write the String intopublic static String writeStringToFile(String s, String fileName, boolean zipCompress)
s
- is the String to writeoutfileName
- is the file name of the file to write the String intozipCompress
- boolean fall to compress with zip compressionWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses