11package geoscript.layer.io
22
3+ import geoscript.feature.Field
4+ import geoscript.feature.Schema
35import geoscript.geom.Bounds
6+ import geoscript.geom.Geometry
7+ import geoscript.geom.Point
48import geoscript.layer.Layer
59import geoscript.layer.Pyramid
610import geoscript.layer.Shapefile
711import geoscript.layer.Tile
12+ import geoscript.workspace.Memory
13+ import geoscript.workspace.Workspace
814import org.junit.Test
915
10- import static org.junit.Assert.assertTrue
16+ import static org.junit.Assert.*
1117
1218/**
1319 * The Pbf Unit Test
@@ -29,4 +35,37 @@ class PbfTestCase {
2935 assertTrue pbfLayer. count > 0
3036 }
3137
38+ @Test void test () {
39+
40+ Workspace workspace = new Memory ()
41+ Schema schema = new Schema (" cities" , [
42+ new Field (" geom" , " Point" , " EPSG:4326" ),
43+ new Field (" id" , " Integer" ),
44+ new Field (" name" , " String" )
45+ ])
46+ Layer layer = workspace. create(schema)
47+ layer. add([
48+ geom : new Point (-122.3204 , 47.6024 ),
49+ id : 1 ,
50+ name : " Seattle"
51+ ])
52+ layer. add([
53+ geom : new Point (-122.48416 , 47.2619 ),
54+ id : 2 ,
55+ name : " Tacoma"
56+ ])
57+
58+ Pyramid pyramid = Pyramid . createGlobalMercatorPyramid(origin : Pyramid.Origin . TOP_LEFT )
59+ Tile tile = new Tile (4 ,2 ,5 )
60+ Bounds bounds = pyramid. bounds(tile)
61+ Bounds projectedBounds = bounds. reproject(" EPSG:4326" )
62+ Geometry projecteBoundsGeom = projectedBounds. geometry
63+
64+ byte [] bytes = Pbf . write([layer], bounds)
65+
66+ List<Layer > layers = Pbf . read(bytes, bounds)
67+ assertEquals (1 , layers. size())
68+ assertEquals (2 , layers[0 ]. count)
69+ }
70+
3271}
0 commit comments