private void createFile(
      CountryRegion global,
      Map<String, Set<TranslateEntity>> translates,
      Map<String, File> polygonFiles,
      String targetObf,
      String targetOsmXml)
      throws IOException, SQLException, InterruptedException, XmlPullParserException {
    File osm = new File(targetOsmXml);
    XmlSerializer serializer = new org.kxml2.io.KXmlSerializer();
    FileOutputStream fous = new FileOutputStream(osm);
    serializer.setOutput(fous, "UTF-8");
    serializer.startDocument("UTF-8", true);
    serializer.startTag(null, "osm");
    serializer.attribute(null, "version", "0.6");
    serializer.attribute(null, "generator", "OsmAnd");
    serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
    for (CountryRegion r : global.children) {
      r.parent = null;
      processRegion(r, translates, polygonFiles, targetObf, targetOsmXml, "", serializer);
    }
    serializer.endDocument();
    serializer.flush();
    fous.close();

    IndexCreator creator = new IndexCreator(new File(targetObf).getParentFile()); // $NON-NLS-1$
    creator.setMapFileName(new File(targetObf).getName());
    creator.setIndexMap(true);
    creator.setIndexAddress(false);
    creator.setIndexPOI(false);
    creator.setIndexTransport(false);
    creator.setIndexRouting(false);
    MapZooms zooms = MapZooms.parseZooms("5-6");
    creator.generateIndexes(
        osm,
        new ConsoleProgressImplementation(1),
        null,
        zooms,
        new MapRenderingTypesEncoder("regions"),
        log);
  }
Exemplo n.º 2
0
  public static void main(String[] args) throws Exception {
    if (args.length == 0) {
      printSynopsys();
    } else {
      String utl = args[0];
      List<String> subArgs = new ArrayList<String>(Arrays.asList(args).subList(1, args.length));
      String[] subArgsArray = subArgs.toArray(new String[args.length - 1]);
      if (utl.equals("check-ocean-tile")) {
        OceanTilesCreator.checkOceanTile(subArgsArray);
      } else if (utl.equals("compare")) {
        BinaryComparator.main(subArgsArray);
      } else if (utl.equals("merge-index")) {
        BinaryMerger.main(subArgsArray);
      } else if (utl.equals("generate-region-tags")) {
        GenerateRegionTags.main(subArgsArray);
      } else if (utl.equals("generate-ocean-tile-osm")) {
        OceanTilesCreator.createJOSMFile(subArgsArray);
      } else if (utl.equals("generate-java-style")) {
        RenderingRulesStoragePrinter.main(subArgsArray);
      } else if (utl.equals("explain-rendering-style")) {
        RenderingRulesStorage.main(subArgsArray);
      } else if (utl.equals("generate-ocean-tile")) {
        OceanTilesCreator.createTilesFile(
            subArgsArray[0], subArgsArray.length > 1 ? args[1] : null);
      } else if (utl.equals("test-routing")) {
        net.osmand.router.TestRouting.main(subArgsArray);
      } else if (utl.equals("generate-ocbf")) {
        CountryOcbfGeneration.main(subArgsArray);
      } else if (utl.equals("generate-obf")) {
        IndexCreator ic = new IndexCreator(new File("."));
        ic.setIndexMap(true);
        ic.setIndexPOI(true);
        ic.setIndexRouting(true);
        ic.setIndexAddress(true);
        ic.setLastModifiedDate(new File(subArgsArray[0]).lastModified());
        generateObf(subArgsArray, ic);
      } else if (utl.equals("generate-map")) {
        IndexCreator ic = new IndexCreator(new File("."));
        ic.setIndexMap(true);
        ic.setLastModifiedDate(new File(subArgsArray[0]).lastModified());
        generateObf(subArgsArray, ic);
      } else if (utl.equals("generate-address")) {
        IndexCreator ic = new IndexCreator(new File("."));
        ic.setIndexAddress(true);
        ic.setLastModifiedDate(new File(subArgsArray[0]).lastModified());
        generateObf(subArgsArray, ic);
      } else if (utl.equals("extract-roads-only")) {
        File mainFile = new File(subArgsArray[0]);
        IndexUploader.extractRoadOnlyFile(
            mainFile,
            new File(
                mainFile.getParentFile(),
                mainFile
                    .getName()
                    .replace(
                        IndexConstants.BINARY_MAP_INDEX_EXT,
                        IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)));
      } else if (utl.equals("generate-poi")) {
        IndexCreator ic = new IndexCreator(new File("."));
        ic.setIndexPOI(true);
        ic.setLastModifiedDate(new File(subArgsArray[0]).lastModified());
        generateObf(subArgsArray, ic);

      } else if (utl.equals("delete-unused-strings")) {
        ResourceDeleter.main(subArgsArray);
      } else if (utl.equals("merge-std-files")) {
        BinaryMerger.mergeStandardFiles(subArgsArray);
      } else if (utl.equals("generate-roads")) {
        IndexCreator ic = new IndexCreator(new File("."));
        ic.setIndexRouting(true);
        ic.setLastModifiedDate(new File(subArgsArray[0]).lastModified());
        generateObf(subArgsArray, ic);
      } else {
        printSynopsys();
      }
    }
  }