Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ dist/
*.zip
testdata/
*.ipynb_checkpoints
data/
2 changes: 1 addition & 1 deletion src/microjson/microjson2vt/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AbstractProjector(ABC):
Concrete classes should implement the project_x and project_y methods.

"""
def __init__(self, bounds):
def __init__(self, bounds=None):
self.bounds = bounds

@abstractmethod
Expand Down
9 changes: 0 additions & 9 deletions src/microjson/microjson2vt/microjson2vt.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def split_tile(self, features, z, x, y, cz=None, cx=None, cy=None):

if tile is None:
# Use simplified geometries for this zoom level

simplified_features = [
{
**feature,
Expand All @@ -262,14 +261,6 @@ def split_tile(self, features, z, x, y, cz=None, cx=None, cy=None):
for feature in features
]

self.tiles[id_] = create_tile(features, z, x, y, options)
tile = self.tiles[id_]
self.tile_coords.append({'z': z, 'x': x, 'y': y})

key = f'z{z}'
self.stats[key] = self.stats.get(key, 0) + 1
self.total += 1

self.tiles[id_] = create_tile(
simplified_features, z, x, y, options)
tile = self.tiles[id_]
Expand Down
2 changes: 1 addition & 1 deletion src/microjson/microjson2vt/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def add_feature(tile, feature, tolerance, options):
tile['maxX'] = max(tile['maxX'], feature['maxX'])
tile['maxY'] = max(tile['maxY'], feature['maxY'])

if type_ == 'Point' or type == 'MultiPoint':
if type_ == 'Point' or type_ == 'MultiPoint':
for i in range(0, len(geom), 3):
simplified.append(geom[i])
simplified.append(geom[i + 1])
Expand Down
4 changes: 2 additions & 2 deletions src/microjson/microjson2vt/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def shift_feature_coords(features, offset):
# new_geometry = None
new_geometry = []

if type_ == 'Pint' or type_ == 'MultiPint' or type_ == 'LineString':
if type_ == 'Point' or type_ == 'MultiPoint' or type_ == 'LineString':
new_geometry = shift_coords(feature.get('geometry'), offset)
elif type_ == 'MultiLineSting' or type_ == 'Polygon':
elif type_ == 'MultiLineString' or type_ == 'Polygon':
new_geometry = []
for line in feature.get('geometry'):
new_geometry.append(shift_coords(line, offset))
Expand Down
5 changes: 3 additions & 2 deletions src/microjson/tilewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def getbounds(microjson_file: str, square: bool = False) -> List[float]:
maxx = max(maxx, coord[0])
maxy = max(maxy, coord[1])
if square:
maxx = max(maxx - minx, maxy - miny) + minx
maxy = max(maxx - minx, maxy - miny) + miny
side = max(maxx - minx, maxy - miny)
maxx = side + minx
maxy = side + miny
return [minx, miny, maxx, maxy]


Expand Down
49 changes: 23 additions & 26 deletions src/microjson/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import re
import shutil
from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import as_completed
from itertools import product

import skimage as sk
Expand Down Expand Up @@ -114,19 +113,18 @@ def _tile_read(self) -> None:
x,
y,
)
if as_completed(future): # type: ignore
label, coordinates = future.result()

if len(label) and len(coordinates) > 0:
label = [i + idx for i in range(
1, len(label) + 1)]
idx = 0
if len(label) == 1:
idx += label[0]
else:
idx += label[-1]
self.polygons_to_microjson(
i, label, coordinates)
label, coordinates = future.result()

if len(label) and len(coordinates) > 0:
label = [i + idx for i in range(
1, len(label) + 1)]
idx = 0
if len(label) == 1:
idx += label[0]
else:
idx += label[-1]
self.polygons_to_microjson(
i, label, coordinates)

else:
future = executor.submit(
Expand All @@ -135,18 +133,17 @@ def _tile_read(self) -> None:
x,
y,
)
if as_completed(future): # type: ignore
label, coordinates = future.result()
if len(label) and len(coordinates) > 0:
label = [i + idx for i in range(
1, len(label) + 1)]
idx = 0
if len(label) == 1:
idx += label[0]
else:
idx += label[-1]
self.polygons_to_microjson(
i, label, coordinates)
label, coordinates = future.result()
if len(label) and len(coordinates) > 0:
label = [i + idx for i in range(
1, len(label) + 1)]
idx = 0
if len(label) == 1:
idx += label[0]
else:
idx += label[-1]
self.polygons_to_microjson(
i, label, coordinates)

def get_line_number(self, filename, target_string) -> int:
line_number = 0
Expand Down