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

Rewrite geometry support #8

Closed
philippkraft opened this issue Jan 2, 2018 · 4 comments
Closed

Rewrite geometry support #8

philippkraft opened this issue Jan 2, 2018 · 4 comments
Assignees
Milestone

Comments

@philippkraft
Copy link
Owner

Follow up to #7.

With using the __geo_interface__, the cells_from_polygons function will get a complete rewrite with API change. The callables are hard to explain and ugly to use.

  • But how to gain that flexibility else?
  • Or is documentation enough?
@philippkraft philippkraft added this to the v1.2 milestone Jan 2, 2018
@philippkraft philippkraft self-assigned this Jan 2, 2018
@philippkraft
Copy link
Owner Author

philippkraft commented Jan 2, 2018

Add a field string cmf::upslope::Cell::WKB in cell.h that can be loaded with a OGC-WKB representation. That WKB can be used to create Shapely-Polygons on the fly.

Creating cells and connecting cells can become two distinct jobs and cells_from_polygons would be simpler.

Challenge

How to mark a std::string as a Python byte-string? swig/swig#752

Idea:

typedef bytestring std::string;
%typemap(out) bytestring {
    $result = PyBytes_FromString($1.c_str());
}

philippkraft added a commit that referenced this issue Jan 2, 2018
Added a get_WKB/set_WKB pair to cmf::upslope::Cell
using the new type cmf::bytestring, a typedef of std::string. time.i
sets swig typemaps to translate bytestring to PyBytes. If shapely
is present __init__.py adds dynamically a geometry property to the
cmf.Cell class.
@philippkraft
Copy link
Owner Author

Current usage for cell geometry now (if shapely is present):

c.geometry = feature.shape

Needed: A cell creator helper function, like:

def make_cell_from_polygon(project, polygon, z, id=None, with_surfacewater=True):
    c=p.NewCell(polygon.centroid.x, polygon.centroid.y, polygon.centroid.z, 
                polygon.area, with_surfaceswater)
    c.geometry = polygon
    if id is not None:
        c.Id = id
    return c

philippkraft added a commit that referenced this issue Jan 4, 2018
@philippkraft
Copy link
Owner Author

Use case for current API in here

@ocni-dtu
Copy link

ocni-dtu commented Jan 6, 2018

I have not encountered any issues with the new make_cell_from_polygons.

I would appreciate if you pushed the work to PyPI.

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

No branches or pull requests

2 participants