Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow to create mbtiles #149

Open
jjcfrancisco opened this issue May 24, 2024 · 0 comments
Open

Workflow to create mbtiles #149

jjcfrancisco opened this issue May 24, 2024 · 0 comments

Comments

@jjcfrancisco
Copy link

This library seem to have most parts to create mbtiles and so I hope this is possible. Using the code below, I am somehow able to get some results. If both minZoom and maxZoom are 0, then the mbtiles displays as it should - they look jagged as I move closer but this is as expected. However, if maxZoom = 5, tiles only show within zoom 0, despite metadata having the correct information and when it moves to zoom 1, the geometry disappears.

I've debugged the tiles coming from tilecover using tiles.ToFeatureCollection and they are correct. The results of layers.Clip is also fine. It seems more linked to the ProjectToTile as the geometries dissapear after zoom 0, although I cannot confirm this. Or maybe there's something I am doing wrong? I'd appreciate some advice/tips/examples.

For this example I used this geojson of Spain.

Ps. I am aware of Tippecanoe but this is not an option I as I am looking for a Go solution.

minZoom = 0
maxZoom = 0

// data := spain.geojson...

var geoms orb.Collection
for _, feature := range data.Features {
	geoms = append(geoms, feature.Geometry)
}

covers := []cover{}
for z := minZoom; z <= maxZoom; z++ {
	tiles, err := tilecover.Collection(geoms, maptile.Zoom(z))
	if err != nil {
		log.Fatal(err)
	}
	cover := cover{tile: tiles}
	covers = append(covers, cover)

}

for cover := range covers {

	layer := mvt.Layer{Name: "spain", Version: 2, Extent: 4096, Features: data.Features}
	layers := mvt.Layers{&layer}
        tile := cover.tile
	layers.Clip(tile.Bound())
	layers.ProjectToTile(tile)
	blob, err := mvt.MarshalGzipped(layers)
	if err != nil {
		log.Fatal(err)
	}
	// Insert blob into Sqlite3 rows

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant