Skip to content

Commit

Permalink
#230 fix ( wkt parsing issue when a task is processed)
Browse files Browse the repository at this point in the history
failed on calculate bbox on wkt, for examaple: '`POLYGON((\n  143 -39,\n  148 -39,\n  148 -44,\n  143 -44,\n  143 -39\n))`'
  • Loading branch information
qifeng-bai committed Jan 25, 2024
1 parent 14c2879 commit f71f2e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,14 @@ class SimpleShapeFile implements Serializable {
static ArrayList<SimpleRegion> parsePolygon(String polygon) {
ArrayList<SimpleRegion> regions = new ArrayList<SimpleRegion>()
for (String p : polygon.split("\\),( )*\\(")) {
//remove return/space that immediately occur after ','
p = p.replaceAll('[\\n]+', '')
//remove space that immediately occur after ','
p = p.replaceAll(',[\\s]+', ',').trim()

regions.add(SimpleRegion.parseSimpleRegion(p))
}

return regions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.apache.commons.io.FileUtils
class Classification extends SlaveProcess {

void start() {

taskLog("Classification is about to start")
//list of layers
List<String> layers = getInput('layer').toString().split(',')
def envnameslist = new String[layers.size()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,7 @@ class SlaveProcess {
}

RegionEnvelope processArea(AreaInput area) {
log.info("Parsing WKT ")
def wkt = getAreaWkt(area)

def region = null
Expand All @@ -1123,7 +1124,7 @@ class SlaveProcess {
} else {
region = SimpleShapeFile.parseWKT(wkt)
}

log.info("Check BBox: " + region?.bounding_box)
new RegionEnvelope(region, envelope)
}

Expand Down

0 comments on commit f71f2e9

Please sign in to comment.