|
1 | 1 | package geoscript.carto |
2 | 2 |
|
3 | 3 | import geoscript.layer.GeoTIFF |
| 4 | +import geoscript.layer.Layer |
4 | 5 | import geoscript.layer.Shapefile |
5 | 6 | import geoscript.render.Map |
| 7 | +import geoscript.style.UniqueValues |
6 | 8 | import org.junit.jupiter.api.io.TempDir |
7 | 9 |
|
8 | 10 | import java.awt.Color |
@@ -65,4 +67,59 @@ all copies or substantial portions of the Software. |
65 | 67 | } |
66 | 68 | } |
67 | 69 |
|
| 70 | + @Test |
| 71 | + void buildAnother() { |
| 72 | + |
| 73 | + Layer layer = new Shapefile(new File(getClass().getClassLoader().getResource("states.shp").toURI())) |
| 74 | + layer.style = new UniqueValues(layer, "SUB_REGION", "Pastel1") |
| 75 | + |
| 76 | + Map map = new Map(layers: [ |
| 77 | + layer |
| 78 | + ]) |
| 79 | + |
| 80 | + boolean saveToTarget = false |
| 81 | + File file = saveToTarget ? new File("target/carto_map.png") : new File(folder, "carto_map.png") |
| 82 | + file.withOutputStream { OutputStream outputStream -> |
| 83 | + new ImageCartoBuilder(PageSize.LETTER_LANDSCAPE, ImageCartoBuilder.ImageType.PNG) |
| 84 | + // Entire Canvas |
| 85 | + .rectangle(new RectangleItem(0, 0, 792, 612).strokeColor(Color.WHITE).fillColor(Color.WHITE)) |
| 86 | + // Outer border |
| 87 | + .rectangle(new RectangleItem(5, 5, 782, 602).strokeColor(Color.BLACK).strokeWidth(3f)) |
| 88 | + // Title border |
| 89 | + .rectangle(new RectangleItem(10, 10, 772, 80).strokeColor(Color.BLACK).strokeWidth(1f)) |
| 90 | + // Map border |
| 91 | + .rectangle(new RectangleItem(10, 95, 600, 490).strokeColor(Color.BLACK).strokeWidth(1f)) |
| 92 | + // Legend border |
| 93 | + .rectangle(new RectangleItem(615, 95, 167, 300).strokeColor(Color.BLACK).strokeWidth(1f)) |
| 94 | + // Scale border |
| 95 | + .rectangle(new RectangleItem(615, 400, 167, 50).strokeColor(Color.BLACK).strokeWidth(1f)) |
| 96 | + // Overview border |
| 97 | + .rectangle(new RectangleItem(615, 455, 167, 80).strokeColor(Color.BLACK).strokeWidth(1f)) |
| 98 | + // Logo border |
| 99 | + .rectangle(new RectangleItem(615, 540, 167, 62).strokeColor(Color.BLACK).strokeWidth(1f)) |
| 100 | + // Title |
| 101 | + .text(new TextItem(15, 15, 700, 60).text("United States").verticalAlign(VerticalAlign.TOP).font(new Font("Arial", Font.BOLD, 36))) |
| 102 | + // Map |
| 103 | + .map(new MapItem(15, 100, 590, 480).map(map)) |
| 104 | + // Legend |
| 105 | + .legend(new LegendItem(620, 100, 157, 290).addMap(map).legendEntryHeight(15).legendEntryWidth(20)) |
| 106 | + // Disclaimer |
| 107 | + .paragraph(new ParagraphItem(15, 587,590, 30).font(new Font("Arial", Font.ITALIC, 8)) |
| 108 | + .text("The map features are approximate and are intended only to provide an indication of said feature. " + |
| 109 | + "Additional areas that have not been mapping may by present. This is not a survey.")) |
| 110 | + // Scale bar |
| 111 | + .scaleBar(new ScaleBarItem(615, 410, 145, 30).map(map).strokeColor(Color.WHITE)) |
| 112 | + // Overview |
| 113 | + .overViewMap(new OverviewMapItem(620, 460, 157, 70).linkedMap(map).overviewMap(map)) |
| 114 | + // North arrow |
| 115 | + .northArrow(new NorthArrowItem(755, 465, 20, 20)) |
| 116 | + // Date text |
| 117 | + .dateText(new DateTextItem(620, 550, 167, 10).font(new Font("Arial", Font.PLAIN, 12))) |
| 118 | + // Logo |
| 119 | + .image(new ImageItem(620, 565, 30, 30).path(new File("src/test/resources/image.png"))) |
| 120 | + .text(new TextItem(655, 565, 100, 30).text("GeoScript").font(new Font("Arial", Font.BOLD, 24))) |
| 121 | + .build(outputStream) |
| 122 | + } |
| 123 | + } |
| 124 | + |
68 | 125 | } |
0 commit comments