Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Commit 34dff6a

Browse files
authored
Merge pull request #44 from MetacitySuite/dev
Deploy PR - removing dependencies
2 parents 68c77c1 + eb8ed5a commit 34dff6a

File tree

11 files changed

+2805
-136
lines changed

11 files changed

+2805
-136
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,3 @@ jobs:
8181
with:
8282
user: __token__
8383
password: ${{ secrets.PYPI_API_TOKEN }}
84-
85-
abort:
86-
runs-on: ubuntu-latest
87-
needs: tag-and-release
88-
if: always() && contains(needs.tag-and-release.result, 'failure')
89-
steps:
90-
- uses: actions/checkout@v2
91-
with:
92-
submodules: 'recursive'
93-
- name: Set up Python 3.8
94-
uses: actions/setup-python@v2
95-
with:
96-
python-version: 3.8
97-
- name: "Get release version"
98-
run: |
99-
CURRENT_VERSION=$(python3 setup.py --version)
100-
echo "Current version: $CURRENT_VERSION"
101-
echo "CURRENT_VERSION=v$CURRENT_VERSION" >> $GITHUB_ENV
102-
- uses: dev-drprasad/[email protected]
103-
with:
104-
delete_release: true
105-
tag_name: ${{ env.CURRENT_VERSION }}
106-
env:
107-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

metacity/geometry/mesh_pipeline/layer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void Layer::to_gltf(const string &filename) const {
3838
}
3939

4040
tinygltf::TinyGLTF gltf;
41-
//gltf.SetStoreOriginalJSONForExtrasAndExtensions(true);
42-
gltf.WriteGltfSceneToFile(&gltf_model, filename, true, true, true, false);
41+
gltf.SetStoreOriginalJSONForExtrasAndExtensions(true);
42+
gltf.WriteGltfSceneToFile(&gltf_model, filename, true, true, true, true);
4343
}
4444

4545
void Layer::simplify_envelope()
@@ -68,7 +68,7 @@ void Layer::from_gltf(const string &filename) {
6868
string err, warn;
6969

7070
Progress bar("Importing models");
71-
bool ret = gltf.LoadASCIIFromFile(&gltf_model, &err, &warn, filename);
71+
bool ret = gltf.LoadBinaryFromFile(&gltf_model, &err, &warn, filename);
7272

7373
if (!err.empty()) {
7474
cout << err << endl;

metacity/io/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
__all__ = ["parse", "parse_recursively"]
88

99

10-
def parse(file: str, from_crs: str = None, to_crs: str = None, progress: Progress = None):
10+
def parse(file: str, progress: Progress = None):
1111
if progress is None:
1212
progress = Progress("Loading Model")
1313

1414
if file.endswith('.shp'):
15-
return parse_shapefile(file, from_crs, to_crs, progress)
15+
return parse_shapefile(file, progress)
1616
elif file.endswith('.json'):
17-
return parse_geojson(file, from_crs, to_crs, progress)
17+
return parse_geojson(file, progress)
1818

1919

20-
def parse_graph(node_file: str, edge_file: str, from_crs: str = None, to_crs: str = None):
21-
return parse_osm_graph(node_file, edge_file, from_crs, to_crs)
20+
def parse_graph(node_file: str, edge_file: str):
21+
return parse_osm_graph(node_file, edge_file)
2222

2323

24-
def parse_recursively(directory: str, from_crs: str = None, to_crs: str = None):
24+
def parse_recursively(directory: str):
2525
models = []
2626
progress = Progress("Loading Models")
2727
for file in fs.list_files_recursive(directory):
28-
submodels = parse(file, from_crs, to_crs, progress)
28+
submodels = parse(file, progress)
2929
if submodels is not None:
3030
models.extend(submodels)
3131
return models

metacity/io/geojson.py

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,14 @@
1-
from numpy import number
21
from metacity.utils.filesystem import read_json
32
from metacity.geometry import Attribute, Model, Progress
43
from typing import List, Union
5-
from pyproj import Proj, Transformer
64

75

86
__all__ = ["parse", "parse_data"]
97

108

11-
12-
class Projector:
13-
def __init__(self, from_crs: str = None, to_crs: str = None):
14-
self.from_crs = from_crs
15-
self.to_crs = to_crs
16-
self.transform = None
17-
18-
if from_crs is None or to_crs is None:
19-
return
20-
21-
proj_from = Proj(from_crs, preserve_units=False)
22-
proj_to = Proj(to_crs, preserve_units=False)
23-
self.transform = Transformer.from_proj(proj_from, proj_to)
24-
25-
def project(self, coordinates: List[List[float]]):
26-
if self.transform is None:
27-
return coordinates
28-
return [ p for p in self.transform.itransform(coordinates) ]
29-
30-
319
class Geometry:
3210
def __init__(self, data):
3311
self.data = data
34-
self.transform = None
3512

3613
@property
3714
def dim(self):
@@ -44,16 +21,6 @@ def dim(self):
4421
f"Encountered primitive with unsupported dimension {d}")
4522
return d
4623

47-
def set_projection(self, projector: Projector):
48-
if projector is None:
49-
return
50-
self.transform = projector.transform
51-
52-
def project(self, coordinates: List[List[float]]):
53-
if self.transform is None:
54-
return coordinates
55-
return [ p for p in self.transform.itransform(coordinates) ]
56-
5724
@property
5825
def coordinates(self):
5926
return self.data['coordinates']
@@ -93,26 +60,23 @@ def to_model(attr: Attribute):
9360
###############################################################################
9461

9562

96-
def parse_point(g: Geometry, attr: Attribute, dim: int, vertices: List[List[float]]):
97-
vertices = g.project(vertices)
63+
def parse_point(attr: Attribute, dim: int, vertices: List[List[float]]):
9864
vertices = flatten(vertices)
9965
if dim == 2:
10066
attr.push_point2D(vertices)
10167
elif dim == 3:
10268
attr.push_point3D(vertices)
10369

10470

105-
def parse_line(g: Geometry, attr: Attribute, dim: int, line: List[List[float]]):
106-
l = g.project(line)
71+
def parse_line(attr: Attribute, dim: int, line: List[List[float]]):
10772
l = flatten(line)
10873
if dim == 2:
10974
attr.push_line2D(l)
11075
elif dim == 3:
11176
attr.push_line3D(l)
11277

11378

114-
def parse_polygon(g: Geometry, attr: Attribute, dim: int, polygon: List[List[List[float]]]):
115-
polygon = [ g.project(p) for p in polygon ]
79+
def parse_polygon(attr: Attribute, dim: int, polygon: List[List[List[float]]]):
11680
p = flatten_polygon(polygon)
11781
if dim == 2:
11882
attr.push_polygon2D(p)
@@ -126,44 +90,44 @@ def parse_polygon(g: Geometry, attr: Attribute, dim: int, polygon: List[List[Lis
12690
def attr_from_point(geometry: Geometry):
12791
attr = Attribute()
12892
vertices = [geometry.coordinates]
129-
parse_point(geometry, attr, geometry.dim, vertices)
93+
parse_point(attr, geometry.dim, vertices)
13094
return [attr]
13195

13296

13397
def attr_from_multipoint(geometry: Geometry):
13498
attr = Attribute()
13599
vertices = geometry.coordinates
136-
parse_point(geometry, attr, geometry.dim, vertices)
100+
parse_point(attr, geometry.dim, vertices)
137101
return [attr]
138102

139103

140104
def attr_from_linestring(geometry: Geometry):
141105
attr = Attribute()
142106
vertices = geometry.coordinates
143-
parse_line(geometry, attr, geometry.dim, vertices)
107+
parse_line(attr, geometry.dim, vertices)
144108
return [attr]
145109

146110

147111
def attr_from_multilinestring(geometry: Geometry):
148112
attr = Attribute()
149113
dim = geometry.dim
150114
for line in geometry.coordinates:
151-
parse_line(geometry, attr, dim, line)
115+
parse_line(attr, dim, line)
152116
return [attr]
153117

154118

155119
def attr_from_polygon(geometry: Geometry):
156120
attr = Attribute()
157121
vertices = geometry.coordinates
158-
parse_polygon(geometry, attr, geometry.dim, vertices)
122+
parse_polygon(attr, geometry.dim, vertices)
159123
return [attr]
160124

161125

162126
def attr_from_multipolygon(geometry: Geometry):
163127
attr = Attribute()
164128
dim = geometry.dim
165129
for polygon in geometry.coordinates:
166-
parse_polygon(geometry, attr, dim, polygon)
130+
parse_polygon(attr, dim, polygon)
167131
return [attr]
168132

169133

@@ -188,8 +152,7 @@ def attr_from_geometrycollection(geometry: Geometry):
188152
}
189153

190154

191-
def parse_geometry(feature: Feature, projector: Projector):
192-
feature.geometry.set_projection(projector)
155+
def parse_geometry(feature: Feature):
193156
if feature.geometry.geometry_type not in typedict:
194157
raise Exception(f"Unknown geometry type {feature.geometry.geometry_type}")
195158
attr_list = typedict[feature.geometry.geometry_type](feature.geometry)
@@ -207,23 +170,22 @@ def parse_models(feature: Feature, attr_list: List[Attribute], progress: Union[P
207170
return models
208171

209172

210-
def parse_feature(feature: Feature, projector: Projector, progress: Progress):
211-
attr_list = parse_geometry(feature, projector)
173+
def parse_feature(feature: Feature, progress: Progress):
174+
attr_list = parse_geometry(feature)
212175
models = parse_models(feature, attr_list, progress)
213176
return models
214177

215178

216-
def parse_data(data, from_crs: str, to_crs: str, progress: Progress = None):
179+
def parse_data(data, progress: Progress = None):
217180
models = []
218-
projector = Projector(from_crs, to_crs)
219181
for f in data['features']:
220182
feature = Feature(f)
221-
models.extend(parse_feature(feature, projector, progress))
183+
models.extend(parse_feature(feature, progress))
222184
return models
223185

224186

225-
def parse(input_file: str, from_crs: str = None, to_crs: str = None, progress: Progress = None):
187+
def parse(input_file: str, progress: Progress = None):
226188
contents = read_json(input_file)
227-
return parse_data(contents, from_crs, to_crs, progress)
189+
return parse_data(contents, progress)
228190

229191

0 commit comments

Comments
 (0)