Beispiel #1
0
  public File writePostScriptToFile(String projectionName, String authorName, String dataLabel)
      throws IOException, AlgorithmExecutionException, TransformException {

    File psFile =
        FileUtilities.createTemporaryFileInDefaultTemporaryDirectory(
            "geoMaps", OUTPUT_FILE_EXTENSION);

    BufferedWriter out = new BufferedWriter(new FileWriter(psFile));

    writeCodeHeader(out, psFile.getName());

    out.write(createPostScriptUtilityDefinitions());
    out.write("\n");

    out.write((new PageHeader(dataLabel, pageHeightInPoints)).toPostScript() + "\n");
    out.write((new PageFooter()).toPostScript() + "\n");

    out.write("% Save the default clipping path so we can clip the map safely" + "\n");
    out.write("gsave" + "\n");
    out.write("\n");

    out.write(mapDisplayer.toPostScript());
    out.write("\n");

    FeaturePrinter featurePrinter =
        new FeaturePrinter(
            featureCollection, geometryProjector, mapDisplayer, shapefileFeatureNameKey);
    featurePrinter.printFeatures(out, featureColorMap);

    CirclePrinter circlePrinter = new CirclePrinter(geometryProjector, mapDisplayer);
    circlePrinter.printCircles(out, circles);

    out.write("% Restore the default clipping path" + "\n");
    out.write("grestore" + "\n");
    out.write("\n");

    PageMetadata pageMetadata = new PageMetadata(TITLE, subtitle);
    pageMetadata.add(projectionName + " Projection");
    pageMetadata.add(timestamp());
    pageMetadata.add(authorName);
    out.write(pageMetadata.toPostScript());
    out.write("\n");

    out.write(legend.toPostScript());
    out.write("\n");

    out.write("showpage" + "\n");

    out.close();

    GeoMapsAlgorithm.logger.log(LogService.LOG_INFO, "Done.");

    return psFile;
  }
Beispiel #2
0
  public ShapefileToPostScriptWriter(URL shapefileURL, String projectionName, String featureNameKey)
      throws AlgorithmExecutionException, TransformException {
    ShapefileFeatureReader shapefileFeatureReader = new ShapefileFeatureReader(shapefileURL);
    this.featureCollection = shapefileFeatureReader.getFeatureCollection();
    this.geometryProjector = makeGeometryProjecter(projectionName);
    this.mapDisplayer = calculateMapBoundingBox();

    this.pageHeightInPoints =
        Constants.calculatePageHeightInPoints(mapDisplayer.getMapHeightInPoints());

    this.shapefileFeatureNameKey = featureNameKey;
  }