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