Skip to content
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
2 changes: 1 addition & 1 deletion jigsawpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* JIGSAW: Interface to the JIGSAW meshing library.
------------------------------------------------------------
*
* Last updated: 13 Aug., 2025
* Last updated: 30 Aug., 2025
*
* Copyright 2019-2025
* Darren Engwirda
Expand Down
69 changes: 51 additions & 18 deletions jigsawpy/parse/loadgeo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

import warnings
import numpy as np
import json
import argparse

from jigsawpy import jigsaw_msh_t, savemsh
from jigsawpy.msh_t import jigsaw_msh_t
from jigsawpy.savemsh import savemsh


def linegeo(line, nset, eset, nobj, last):
Expand All @@ -30,7 +32,13 @@ def linegeo(line, nset, eset, nobj, last):

last = last + npts

temp.vert2["coord"] = line[+0::]
data = np.asarray(line)
if (data.shape[1] > 2):
warnings.warn("Z-COORD omitted", Warning)

# omit z if [x,y,z]
temp.vert2["coord"][:, 0] = data[+0:, 0]
temp.vert2["coord"][:, 1] = data[+0:, 1]

temp.edge2["index"][:, 0] = indx + 0
temp.edge2["index"][:, 1] = indx + 1
Expand Down Expand Up @@ -75,7 +83,13 @@ def polygeo(loop, nset, eset, nobj, last):

last = last + npts

temp.vert2["coord"] = loop[:-1:]
data = np.asarray(loop)
if (data.shape[1] > 2):
warnings.warn("Z-COORD omitted", Warning)

# omit z if [x,y,z]
temp.vert2["coord"][:, 0] = data[:-1, 0]
temp.vert2["coord"][:, 1] = data[:-1, 1]

temp.edge2["index"][:, 0] = idx1
temp.edge2["index"][:, 1] = idx2
Expand All @@ -92,28 +106,28 @@ def readgeo(geom, nset, eset, nobj, last):

"""

if (geom["type"] == "LineString"):
if (geom["type"].lower() == "linestring"):

line = geom["coordinates"]

nobj, last = linegeo(
line, nset, eset, nobj, last)

elif (geom["type"] == "MultiLineString"):
elif (geom["type"].lower() == "multilinestring"):

for line in geom["coordinates"]:

nobj, last = linegeo(
line, nset, eset, nobj, last)

elif (geom["type"] == "Polygon"):
elif (geom["type"].lower() == "polygon"):

for loop in geom["coordinates"]:

nobj, last = polygeo(
loop, nset, eset, nobj, last)

elif (geom["type"] == "MultiPolygon"):
elif (geom["type"].lower() == "multipolygon"):

for poly in geom["coordinates"]:
for loop in poly:
Expand All @@ -124,6 +138,29 @@ def readgeo(geom, nset, eset, nobj, last):
return nobj, last


def readobj(feat, nset, eset, nobj, last):
"""
READOBJ: read a geoJSON feat into a jigsaw msh_t object.

"""

if (feat["type"].lower() != "geometrycollection"):

geom = feat["geometry"]

nobj, last = readgeo(
geom, nset, eset, nobj, last)

else:

for geom in feat["geometries"]:

nobj, last = readgeo(
geom, nset, eset, nobj, last)

return nobj, last


def loadgeo(name, mesh):
"""
LOADGEO: load a geoJSON file into a jigsaw msh_t object.
Expand All @@ -140,21 +177,17 @@ def loadgeo(name, mesh):

with open(name) as f: geoj = json.load(f)

for feat in geoj["features"]:

geom = (feat["geometry"])

if (geom["type"] != "GeometryCollection"):
if (geoj["type"].lower() != "featurecollection"):

nobj, last = readgeo(
geom, nset, eset, nobj, last)
nobj, last = readobj(
geoj, nset, eset, nobj, last)

else:
else:

for next in geom["geometries"]:
for feat in geoj["features"]:

nobj, last = readgeo(
next, nset, eset, nobj, last)
nobj, last = readobj(
feat, nset, eset, nobj, last)

mesh.vert2 = np.concatenate(nset, axis=0)
mesh.edge2 = np.concatenate(eset, axis=0)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "jigsawpy"
version = "1.1.0"
version = "1.1.1"
description = "Python interface for the JIGSAW meshing library."
readme = "README.md"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
AUTHOR = "Darren Engwirda"
AUTHOR_EMAIL = "d.engwirda@gmail.com"
URL = "https://github.com/dengwirda/"
VERSION = "1.1.0"
VERSION = "1.1.1"
REQUIRES_PYTHON = ">=3.6.0"
KEYWORDS = "Mesh-generation Delaunay Voronoi"

Expand Down
Loading