| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,5 +21,6 @@ | |||
| 21 | 21 | author_email = '', | |
| 22 | 22 | license = 'MIT', | |
| 23 | 23 | packages = setuptools.find_packages(), | |
| 24 | + scripts = ['bin/mander'], | ||
| 24 | 25 | ext_modules = ext_modules | |
| 25 | 26 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,12 +35,18 @@ void addScoresToNewShapefile(const std::string in_filename, const std::string ou | |||
| 35 | 35 | PYBIND11_PLUGIN(_mander) { | |
| 36 | 36 | py::module m("_mander", "Internal library used by python-mander to calculate scores"); | |
| 37 | 37 | ||
| 38 | + m.def( | ||
| 39 | + "getListOfScores", | ||
| 40 | + &getListOfScores, | ||
| 41 | + "Returns a list of compactness scores." | ||
| 42 | + ); | ||
| 43 | + | ||
| 38 | 44 | m.def( | |
| 39 | 45 | "getScoresForGeoJSON", | |
| 40 | 46 | &getScoresForGeoJSON, | |
| 41 | 47 | "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.", | |
| 42 | 48 | py::arg("geojson"), | |
| 43 | - py::arg("id")="" | ||
| 49 | + py::arg("id")="", | ||
| 44 | 50 | py::arg("score_list")="" | |
| 45 | 51 | ); | |
| 46 | 52 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments