FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Eliminated Python code that's been replaced by compactnesslib. · PibeG/python-mander@a85574c · GitHub

Commit a85574c

Browse files
committed
Eliminated Python code that's been replaced by compactnesslib.
Created Python wrapping functions
1 parent 9262874 commit a85574c

7 files changed

Lines changed: 67 additions & 203 deletions

File tree

‎mander/__init__.py‎

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
1-
from _mander import *
1+
import _mander
2+
3+
4+
def getListOfScores():
5+
"""Returns a list of scores the library can calculate.
6+
Subsets of this list may be passed to the other functions in the library.
7+
"""
8+
return _mander.getListOfScores()
9+
10+
11+
12+
def getScoresForGeoJSON(geojson, id="", score_list=[]):
13+
"""Calculates scores for a given GeoJSON string.
14+
15+
Parameters:
16+
geojson -- GeoJSON string for which to calculate scores.
17+
id -- An attribute value used to key the JSON output
18+
score_list -- A list of scores to calculate. Valid values from `getListOfScores()`
19+
An empty list indicates all scores should be calculated.
20+
21+
Returns:
22+
A JSON dictionary whose keys are taken from `id` or are the 0-based index
23+
number of the multipolygon for which the scores were calculated.
24+
"""
25+
26+
return _mander.getScoresForGeoJSON(geojson,id,score_list)
27+
28+
29+
30+
def augmentShapefileWithScores(filename, score_list=[]):
31+
"""Adds indicated scores to an existing shapefile
32+
33+
Parameters:
34+
filename -- File to which scores should be added
35+
score_list -- A list of scores to calculate. Valid values from `getListOfScores()`
36+
An empty list indicates all scores should be calculated.
37+
38+
Returns:
39+
No return. The file is modified or an exception is thrown.
40+
"""
41+
42+
return _mander.augmentShapefileWithScores(filename,score_list)
43+
44+
45+
46+
def addScoresToNewShapefile(in_filename, out_filename, score_list=[]):
47+
"""Adds indicated scores to an existing shapefile
48+
49+
Parameters:
50+
in_filename -- File to which scores should be added
51+
out_filename -- Filename of new shapefile which will contain the scores
52+
score_list -- A list of scores to calculate. Valid values from `getListOfScores()`
53+
An empty list indicates all scores should be calculated.
54+
55+
Returns:
56+
No return. The new shapefile is built or an exception is thrown.
57+
"""
58+
59+
return _mander.addScoresToNewShapefile(in_filename,out_filename,score_list)

‎mander/districts.py‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎mander/metrics.py‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎mander/minBoundingCircle.py‎

Lines changed: 0 additions & 130 deletions
This file was deleted.

‎mander/utils.py‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎setup.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
author_email = '',
2222
license = 'MIT',
2323
packages = setuptools.find_packages(),
24+
scripts = ['bin/mander'],
2425
ext_modules = ext_modules
2526
)

‎src/pywrapper.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ void addScoresToNewShapefile(const std::string in_filename, const std::string ou
3535
PYBIND11_PLUGIN(_mander) {
3636
py::module m("_mander", "Internal library used by python-mander to calculate scores");
3737

38+
m.def(
39+
"getListOfScores",
40+
&getListOfScores,
41+
"Returns a list of compactness scores."
42+
);
43+
3844
m.def(
3945
"getScoresForGeoJSON",
4046
&getScoresForGeoJSON,
4147
"Takes a GeoJSON string as input, calculates all scores, return a JSON dictionary of the scores keyed to values identified 'id' which are expected to be properties of the GeoJSON objects. If id='', then the object's 0-indexed order is used.",
4248
py::arg("geojson"),
43-
py::arg("id")=""
49+
py::arg("id")="",
4450
py::arg("score_list")=""
4551
);
4652

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL