001: /*---------------- FILE HEADER ------------------------------------------
002:
003: This file is part of deegree.
004: Copyright (C) 2001-2008 by:
005: EXSE, Department of Geography, University of Bonn
006: http://www.giub.uni-bonn.de/deegree/
007: lat/lon GmbH
008: http://www.lat-lon.de
009:
010: This library is free software; you can redistribute it and/or
011: modify it under the terms of the GNU Lesser General Public
012: License as published by the Free Software Foundation; either
013: version 2.1 of the License, or (at your option) any later version.
014:
015: This library is distributed in the hope that it will be useful,
016: but WITHOUT ANY WARRANTY; without even the implied warranty of
017: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
018: Lesser General Public License for more details.
019:
020: You should have received a copy of the GNU Lesser General Public
021: License along with this library; if not, write to the Free Software
022: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
023:
024: Contact:
025:
026: Andreas Poth
027: lat/lon GmbH
028: Aennchenstraße 19
029: 53177 Bonn
030: Germany
031: E-Mail: poth@lat-lon.de
032:
033: Prof. Dr. Klaus Greve
034: Department of Geography
035: University of Bonn
036: Meckenheimer Allee 166
037: 53115 Bonn
038: Germany
039: E-Mail: greve@giub.uni-bonn.de
040:
041: ---------------------------------------------------------------------------*/
042: package org.deegree.tools.app3d;
043:
044: import java.io.File;
045: import java.io.FileOutputStream;
046: import java.net.URL;
047: import java.util.HashMap;
048: import java.util.Properties;
049:
050: import org.deegree.framework.xml.XMLFragment;
051: import org.deegree.framework.xml.XSLTDocument;
052:
053: /**
054: * Utility program for converting a CityGML documents in KML. At the moment just Buildings are
055: * supported.
056: *
057: * @version $Revision: 1.2 $
058: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
059: * @author last edited by: $Author: poth $
060: *
061: * @version 1.0. $Revision: 1.2 $, $Date: 2007/01/23 19:42:39 $
062: *
063: * @since 2.0
064: */
065: public class CityGML2KML {
066:
067: private static URL xslt = CityGML2KML.class
068: .getResource("citygml2kml.xsl");
069:
070: /**
071: * @param args may be -sourceFile, -outFile, -sourceCRS
072: * @throws Exception
073: */
074: public static void main(String[] args) throws Exception {
075:
076: Properties map = new Properties();
077: for (int i = 0; i < args.length; i += 2) {
078: map.put(args[i], args[i + 1]);
079: }
080:
081: if (map.getProperty("-sourceFile") == null) {
082: System.out.println("parameter -sourceFile must be set");
083: return;
084: }
085: if (map.getProperty("-outFile") == null) {
086: System.out.println("parameter -outFile must be set");
087: return;
088: }
089:
090: HashMap<String, String> params = new HashMap<String, String>();
091: if (map.get("-sourceCRS") != null) {
092: params.put("SRCCRS", map.getProperty("-sourceCRS"));
093: } else {
094: System.out
095: .println("use default source CRS (-sourceCRS EPSG:31467)");
096: }
097:
098: XSLTDocument outXSLSheet = new XSLTDocument();
099: outXSLSheet.load(xslt);
100:
101: XMLFragment doc = new XMLFragment();
102: doc.load(new File(map.getProperty("-sourceFile")).toURL());
103:
104: XMLFragment resultDocument = outXSLSheet.transform(doc,
105: XMLFragment.DEFAULT_URL, null, params);
106:
107: FileOutputStream fos = new FileOutputStream(map
108: .getProperty("-outFile"));
109: resultDocument.write(fos);
110: fos.close();
111: }
112:
113: }
|