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

remove option shaderscolumn #172

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ If --username and/or --dbname are not specified the current username is used as

-g, --geometricerrors (Default: 2000,0) Geometric errors (Cesium)

--shaderscolumn (Default: '') shaders column (Cesium)

--use_implicit_tiling (Default: true) use 1.1 implicit tiling (Cesium)

--add_outlines (Default: false) Add outlines (Cesium)
Expand All @@ -208,7 +206,7 @@ If --username and/or --dbname are not specified the current username is used as
Sample command for running pg2b3dm:

```
$ pg2b3dm -h localhost -U postgres -c geom_triangle --shaderscolumn shaders -t delaware_buildings -d postgres -g 100,0
$ pg2b3dm -h localhost -U postgres -c geom_triangle -t delaware_buildings -d postgres -g 100,0
```

Database password will be asked to create the database connection, unless:
Expand Down
2 changes: 1 addition & 1 deletion cesium_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ for example visualize a simplified geometry when the camera is far away, and a m
Sample command for using LOD's:

```
-h localhost -U postgres -c geom_triangle --shaderscolumn shaders -t delaware_buildings_lod -d postgres -g 1000,100,0 --lodcolumn lodcolumn --use_implicit_tiling false --max_features_per_tile 1000
-h localhost -U postgres -c geom_triangle -t delaware_buildings_lod -d postgres -g 1000,100,0 --lodcolumn lodcolumn --use_implicit_tiling false --max_features_per_tile 1000
```

The LOD function will be enabled when parameter --lodcolumn is not empty.
Expand Down
24 changes: 5 additions & 19 deletions src/b3dm.tileset/GeometryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ public static double[] GetGeometriesBoundingBox(NpgsqlConnection conn, string ge
return result;
}

public static List<GeometryRecord> GetGeometrySubset(NpgsqlConnection conn, string geometry_table, string geometry_column, double[] bbox, int source_epsg, int target_srs, string shaderColumn = "", string attributesColumns = "", string query = "", string radiusColumn = "")
public static List<GeometryRecord> GetGeometrySubset(NpgsqlConnection conn, string geometry_table, string geometry_column, double[] bbox, int source_epsg, int target_srs, string attributesColumns = "", string query = "", string radiusColumn = "")
{
var sqlselect = GetSqlSelect(geometry_column, shaderColumn, attributesColumns, radiusColumn, target_srs);
var sqlselect = GetSqlSelect(geometry_column, attributesColumns, radiusColumn, target_srs);
var sqlFrom = "FROM " + geometry_table;

var b = GetTileBoundingBox(bbox);

var sqlWhere = GetWhere(geometry_column, source_epsg, b.xmin, b.ymin, b.xmax, b.ymax, query);
var sql = sqlselect + sqlFrom + sqlWhere;

var geometries = GetGeometries(conn, shaderColumn, attributesColumns, sql, radiusColumn);
var geometries = GetGeometries(conn, attributesColumns, sql, radiusColumn);
return geometries;
}

Expand All @@ -68,13 +68,10 @@ public static string GetWhere(string geometry_column, int source_epsg, string xm
$") {query}";
}

public static string GetSqlSelect(string geometry_column, string shaderColumn, string attributesColumns, string radiusColumn, int target_srs)
public static string GetSqlSelect(string geometry_column, string attributesColumns, string radiusColumn, int target_srs)
{
var g = GetGeometryColumn(geometry_column, target_srs);
var sqlselect = $"SELECT ST_AsBinary({g})";
if (shaderColumn != String.Empty) {
sqlselect = $"{sqlselect}, {shaderColumn} ";
}
if (attributesColumns != String.Empty) {
sqlselect = $"{sqlselect}, {attributesColumns} ";
}
Expand All @@ -90,26 +87,19 @@ public static string GetGeometryColumn(string geometry_column, int target_srs)
return $"st_transform({geometry_column}, {target_srs})";
}

public static List<GeometryRecord> GetGeometries(NpgsqlConnection conn, string shaderColumn, string attributesColumns, string sql, string radiusColumn)
public static List<GeometryRecord> GetGeometries(NpgsqlConnection conn, string attributesColumns, string sql, string radiusColumn)
{
var geometries = new List<GeometryRecord>();
conn.Open();
var cmd = new NpgsqlCommand(sql, conn);
var reader = cmd.ExecuteReader();
var attributesColumnIds = new Dictionary<string, int>();
var shadersColumnId = int.MinValue;
var radiusColumnId = int.MinValue;

if (attributesColumns != String.Empty) {
var attributesColumnsList = attributesColumns.Split(',').ToList();
attributesColumnIds = FindFields(reader, attributesColumnsList);
}
if (shaderColumn != String.Empty) {
var fld = FindField(reader, shaderColumn);
if (fld.HasValue) {
shadersColumnId = FindField(reader, shaderColumn).Value;
}
}
if (radiusColumn != String.Empty) {
var fld = FindField(reader, radiusColumn);
if (fld.HasValue) {
Expand All @@ -124,10 +114,6 @@ public static List<GeometryRecord> GetGeometries(NpgsqlConnection conn, string s
var geom = Geometry.Deserialize<WkbSerializer>(stream);
var geometryRecord = new GeometryRecord(batchId) { Geometry = geom };

if (shaderColumn != string.Empty) {
var json = GetJson(reader, shadersColumnId);
geometryRecord.Shader = JsonConvert.DeserializeObject<ShaderColors>(json);
}
if (attributesColumns != string.Empty) {
var attributes = GetColumnValuesAsList(reader, attributesColumnIds);
geometryRecord.Attributes = attributes;
Expand Down
6 changes: 2 additions & 4 deletions src/b3dm.tileset/QuadtreeTiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class QuadtreeTiler
private readonly int maxFeaturesPerTile;
private readonly string query;
private readonly double[] translation;
private readonly string colorColumn;
private readonly string attributesColumn;
private readonly string lodColumn;
private readonly string outputFolder;
Expand All @@ -28,7 +27,7 @@ public class QuadtreeTiler
private readonly bool skipCreateTiles;
private readonly string radiusColumn;

public QuadtreeTiler(NpgsqlConnection conn, string table, int source_epsg, string geometryColumn, int maxFeaturesPerTile, string query, double[] translation, string colorColumn, string attributesColumn, string lodColumn, string outputFolder, List<int> lods, string copyright = "", bool skipCreateTiles = false, string radiusColumn = "")
public QuadtreeTiler(NpgsqlConnection conn, string table, int source_epsg, string geometryColumn, int maxFeaturesPerTile, string query, double[] translation, string attributesColumn, string lodColumn, string outputFolder, List<int> lods, string copyright = "", bool skipCreateTiles = false, string radiusColumn = "")
{
this.table = table;
this.conn = conn;
Expand All @@ -37,7 +36,6 @@ public QuadtreeTiler(NpgsqlConnection conn, string table, int source_epsg, strin
this.maxFeaturesPerTile = maxFeaturesPerTile;
this.query = query;
this.translation = translation;
this.colorColumn = colorColumn;
this.attributesColumn = attributesColumn;
this.lodColumn = lodColumn;
this.outputFolder = outputFolder;
Expand Down Expand Up @@ -105,7 +103,7 @@ public List<Tile> GenerateTiles(BoundingBox bbox, Tile tile, List<Tile> tiles, i

if (!skipCreateTiles) {

var geometries = GeometryRepository.GetGeometrySubset(conn, table, geometryColumn, tile.BoundingBox, source_epsg, target_srs, colorColumn, attributesColumn, where, radiusColumn);
var geometries = GeometryRepository.GetGeometrySubset(conn, table, geometryColumn, tile.BoundingBox, source_epsg, target_srs, attributesColumn, where, radiusColumn);
// var scale = new double[] { 1, 1, 1 };
bytes = TileWriter.ToTile(geometries, translation, copyright: copyright, addOutlines: addOutlines, defaultColor: defaultColor, defaultMetallicRoughness: defaultMetallicRoughness, doubleSided: doubleSided, createGltf: createGltf);
if (bytes != null) {
Expand Down
3 changes: 0 additions & 3 deletions src/pg2b3dm.database.tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public void ImplicitTilingTest()
var trans = new double[] { translation.X, translation.Y, translation.Z };
var implicitTiler = new QuadtreeTiler(conn, "delaware_buildings", 4326, "geom_triangle", 50, string.Empty,
trans,
"shaders",
string.Empty,
string.Empty,
"output/content",
Expand Down Expand Up @@ -95,7 +94,6 @@ public void LodTest()

var implicitTiler = new QuadtreeTiler(conn, "delaware_buildings_lod", 4326, "geom_triangle", 10, string.Empty,
trans,
"shaders",
string.Empty,
"lodcolumn",
"output/content",
Expand Down Expand Up @@ -123,7 +121,6 @@ public void GeometryTest()
trans,
string.Empty,
string.Empty,
string.Empty,
"output/content",
new List<int>() { 0 },
skipCreateTiles: false);
Expand Down
4 changes: 2 additions & 2 deletions src/pg2b3dm/MapboxTiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace pg2b3dm;
public static class MapboxTiler
{
public static void CreateMapboxTiles(string table, string geometryColumn, string defaultColor, string defaultMetallicRoughness, bool createGltf, int zoom, string shadersColumn, string attributeColumns, string copyright, string query, NpgsqlConnection conn, int source_epsg, BoundingBox bbox, string contentDirectory)
public static void CreateMapboxTiles(string table, string geometryColumn, string defaultColor, string defaultMetallicRoughness, bool createGltf, int zoom, string attributeColumns, string copyright, string query, NpgsqlConnection conn, int source_epsg, BoundingBox bbox, string contentDirectory)
{
// mapbox specific code

Expand Down Expand Up @@ -40,7 +40,7 @@ public static void CreateMapboxTiles(string table, string geometryColumn, string
var height = ul_spherical[1] - ll_spherical[1];

var ext = createGltf ? "glb" : "b3dm";
var geometries = GeometryRepository.GetGeometrySubset(conn, table, geometryColumn, bounds, source_epsg, target_srs, shadersColumn, attributeColumns, query1);
var geometries = GeometryRepository.GetGeometrySubset(conn, table, geometryColumn, bounds, source_epsg, target_srs, attributeColumns, query1);

// in Mapbox mode, every tile has 2^13 = 8192 values
// see https://github.com/mapbox/mapbox-gl-js/blob/main/src/style-spec/data/extent.js
Expand Down
3 changes: 0 additions & 3 deletions src/pg2b3dm/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public class Options
[Option('f', "format", Required = false, Default = AppMode.Cesium, HelpText = "Format (Mapbox or Cesium)")]
public AppMode AppMode { get; set; }

[Option("shaderscolumn", Required = false, Default = "", HelpText = "shaders column")]
public string ShadersColumn { get; set; }

// cesium specific options
[Option("max_features_per_tile", Required = false, Default = 1000, HelpText = "maximum features per tile (Cesium)", SetName = "Cesium")]
public int MaxFeaturesPerTile { get; set; }
Expand Down
5 changes: 2 additions & 3 deletions src/pg2b3dm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ static void Main(string[] args)
var createGltf = (bool)o.CreateGltf;
var outputDirectory = o.Output;
var zoom = o.Zoom;
var shadersColumn = o.ShadersColumn;
var attributeColumns = o.AttributeColumns;
var copyright = o.Copyright;

Expand Down Expand Up @@ -183,7 +182,7 @@ static void Main(string[] args)
var tile = new Tile(0, 0, 0);
tile.BoundingBox = bbox.ToArray();
Console.WriteLine($"Start generating tiles...");
var quadtreeTiler = new QuadtreeTiler(conn, table, source_epsg, geometryColumn, o.MaxFeaturesPerTile, query, translation, o.ShadersColumn, o.AttributeColumns, lodcolumn, contentDirectory, lods, o.Copyright, skipCreateTiles, o.RadiusColumn);
var quadtreeTiler = new QuadtreeTiler(conn, table, source_epsg, geometryColumn, o.MaxFeaturesPerTile, query, translation, o.AttributeColumns, lodcolumn, contentDirectory, lods, o.Copyright, skipCreateTiles, o.RadiusColumn);
var tiles = quadtreeTiler.GenerateTiles(bbox, tile, new List<Tile>(), lodcolumn != string.Empty ? lods.First() : 0, addOutlines, defaultColor, defaultMetallicRoughness, doubleSided, createGltf);
Console.WriteLine();
Console.WriteLine("Tiles created: " + tiles.Count(tile => tile.Available));
Expand All @@ -204,7 +203,7 @@ static void Main(string[] args)

}
else {
MapboxTiler.CreateMapboxTiles(table, geometryColumn, defaultColor, defaultMetallicRoughness, createGltf, zoom, shadersColumn, attributeColumns, copyright, query, conn, source_epsg, bbox, contentDirectory);
MapboxTiler.CreateMapboxTiles(table, geometryColumn, defaultColor, defaultMetallicRoughness, createGltf, zoom, attributeColumns, copyright, query, conn, source_epsg, bbox, contentDirectory);
}

stopWatch.Stop();
Expand Down
Loading