From 35695bfd2b6a41d9515264686580a0095cbcfd03 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 27 Dec 2011 00:15:27 +0100 Subject: [PATCH] New generation build --- DataExtractionOSM/build.xml | 2 +- .../osmand/data/index/IndexBatchCreator.java | 58 +-- .../src/net/osmand/data/index/batch.xml | 2 +- .../src/net/osmand/data/index/regions.xml | 2 +- build-scripts/indexes-batch-generate.xml | 41 ++ build-scripts/indexes-generate.sh | 11 + build-scripts/indexes-regions.xml | 484 ++++++++++++++++++ 7 files changed, 564 insertions(+), 36 deletions(-) create mode 100644 build-scripts/indexes-batch-generate.xml create mode 100644 build-scripts/indexes-generate.sh create mode 100644 build-scripts/indexes-regions.xml diff --git a/DataExtractionOSM/build.xml b/DataExtractionOSM/build.xml index 3f4766a19f..c2e3d84f72 100644 --- a/DataExtractionOSM/build.xml +++ b/DataExtractionOSM/build.xml @@ -90,10 +90,10 @@ + - diff --git a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java index 0dbc3d844c..69ddf12adc 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java @@ -106,7 +106,6 @@ public class IndexBatchCreator { String cookieSID = ""; String pagegen = ""; String token = ""; - private boolean local; public static void main(String[] args) { @@ -119,25 +118,35 @@ public class IndexBatchCreator { } String name = args[0]; InputStream stream; + InputStream regionsStream = null; if(name.equals("-local")){ stream = IndexBatchCreator.class.getResourceAsStream("batch.xml"); - creator.setLocal(true); + regionsStream = IndexBatchCreator.class.getResourceAsStream("regions.xml"); } else { try { stream = new FileInputStream(name); } catch (FileNotFoundException e) { - System.out.println("XML configuration file not found : " + name); - return; + throw new IllegalArgumentException("XML configuration file not found : " + name, e); + } + if (args.length > 1) { + try { + File regionsFile = new File(args[1]); + regionsStream = new FileInputStream(regionsFile); + } catch (FileNotFoundException e) { + throw new IllegalArgumentException("Please specify xml-file with regions to download", e); //$NON-NLS-1$ + } } } - - if(args.length >= 2 && args[1] != null && args[1].startsWith("-gp")){ - creator.googlePassword = args[1].substring(3); - } + try { Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(stream); - creator.runBatch(doc); + Document regions = null; + if(regionsStream != null) { + name = args[1]; + regions = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(regionsStream); + } + creator.runBatch(doc, regions); } catch (SAXException e) { System.out.println("XML configuration file could not be read from " + name); e.printStackTrace(); @@ -155,11 +164,7 @@ public class IndexBatchCreator { } } - private void setLocal(boolean local) { - this.local = local; - } - - public void runBatch(Document doc) throws SAXException, IOException, ParserConfigurationException{ + public void runBatch(Document doc, Document regions) throws SAXException, IOException, ParserConfigurationException{ NodeList list = doc.getElementsByTagName("process"); if(list.getLength() != 1){ throw new IllegalArgumentException("You should specify exactly 1 process element!"); @@ -193,22 +198,10 @@ public class IndexBatchCreator { throw new IllegalArgumentException("Please specify directory with generated index files as directory_for_index_files (attribute)"); //$NON-NLS-1$ } indexDirFiles = new File(dir); - InputStream regionsStream = null; - if(downloadFiles){ - dir = process.getAttribute("list_download_regions_file"); - if(!Algoritms.isEmpty(dir)) { - File regionsFile = new File(dir); - if(!regionsFile.exists()){ - if (local) { - regionsStream = IndexBatchCreator.class.getResourceAsStream("regions.xml"); - } - if (regionsStream == null) { - throw new IllegalArgumentException("Please specify file with regions to download as list_download_regions_file (attribute)"); //$NON-NLS-1$ - } - } else { - regionsStream = new FileInputStream(regionsFile); - } - } + if (downloadFiles) { + if (regions == null) { + throw new IllegalArgumentException("Please specify regions.xml file as 2nd parameter"); + } } dir = process.getAttribute("directory_for_uploaded_files"); @@ -256,9 +249,8 @@ public class IndexBatchCreator { List countriesToDownload = new ArrayList(); parseCountriesToDownload(doc, countriesToDownload); - if(regionsStream != null){ - Document innerDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(regionsStream); - parseCountriesToDownload(innerDoc, countriesToDownload); + if (regions != null) { + parseCountriesToDownload(regions, countriesToDownload); } runBatch(countriesToDownload); diff --git a/DataExtractionOSM/src/net/osmand/data/index/batch.xml b/DataExtractionOSM/src/net/osmand/data/index/batch.xml index b94805fe51..df837bb05d 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/batch.xml +++ b/DataExtractionOSM/src/net/osmand/data/index/batch.xml @@ -27,7 +27,7 @@ --> diff --git a/DataExtractionOSM/src/net/osmand/data/index/regions.xml b/DataExtractionOSM/src/net/osmand/data/index/regions.xml index f51e140a13..1c6911f780 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/regions.xml +++ b/DataExtractionOSM/src/net/osmand/data/index/regions.xml @@ -1,6 +1,6 @@ - + diff --git a/build-scripts/indexes-batch-generate.xml b/build-scripts/indexes-batch-generate.xml new file mode 100644 index 0000000000..1ea1c8598f --- /dev/null +++ b/build-scripts/indexes-batch-generate.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + diff --git a/build-scripts/indexes-generate.sh b/build-scripts/indexes-generate.sh new file mode 100644 index 0000000000..bb206f8124 --- /dev/null +++ b/build-scripts/indexes-generate.sh @@ -0,0 +1,11 @@ +# remove backup and create new backup +# we should not rm, just do incremental updates for now! rm -rf backup +mkdir -p ~/backup +mv ~/indexes/uploaded/*.* backup + +# remove all previous files +rm -rf ~/indexes +mkdir ~/indexes + +cd ../DataExtractionOSM +java -Djava.util.logging.config.file=logging.properties -Xms64M -Xmx720M -cp "./OsmAndMapCreator.jar:./lib/*.jar" net.osmand.data.index.IndexBatchCreator ../build-scripts/indexes-batch-generate.xml ../build-scripts/indexes-regions.xml diff --git a/build-scripts/indexes-regions.xml b/build-scripts/indexes-regions.xml new file mode 100644 index 0000000000..279bed38b8 --- /dev/null +++ b/build-scripts/indexes-regions.xml @@ -0,0 +1,484 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +