Skip to content

Commit 38ca917

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents dd784c4 + 221fcd6 commit 38ca917

9 files changed

Lines changed: 27 additions & 22 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
version "3.0.0"
2+
version "3.1.0"
33
group "au.org.ala"
44
}
55

grails-app/conf/logback.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<logger name="au.org.ala.spatial" level="WARN"/>
2424
<logger name="org.liquibase" level="WARN"/>
2525
<logger name="liquibase" level="WARN"/>
26+
<logger name="org.pac4j.oidc.profile.creator.TokenValidator" level="ERROR"/>
2627

2728
<root level="WARN">
2829
<appender-ref ref="STDOUT"/>

grails-app/services/au/org/ala/spatial/SpatialObjectsService.groovy

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import au.org.ala.spatial.intersect.Grid
2121
import au.org.ala.spatial.dto.LayerFilter
2222
import au.org.ala.spatial.util.SpatialConversionUtils
2323
import au.org.ala.spatial.util.SpatialUtils
24-
import grails.converters.JSON
2524
import groovy.sql.GroovyResultSet
2625
import groovy.sql.Sql
2726
import groovy.util.logging.Slf4j
@@ -41,7 +40,6 @@ import org.locationtech.jts.io.WKTReader
4140
import org.opengis.feature.simple.SimpleFeature
4241
import org.opengis.feature.simple.SimpleFeatureType
4342
import org.springframework.dao.DataAccessException
44-
import org.springframework.scheduling.annotation.Async
4543
import org.springframework.transaction.annotation.Transactional
4644

4745
import java.nio.charset.StandardCharsets
@@ -90,7 +88,7 @@ class SpatialObjectsService {
9088

9189
}
9290

93-
LayerIntersectService layerIntersectDao
91+
LayerIntersectService layerIntersectService
9492
LayerService layerService
9593
def Holders
9694
def dataSource
@@ -142,7 +140,7 @@ class SpatialObjectsService {
142140
if (pageSize == -1 || (pos >= start && pos - start < pageSize)) {
143141
SpatialObjects o = new SpatialObjects()
144142
o.setPid(f.getLayerPid() + ':' + c.getKey())
145-
o.setId(f.getLayerPid() + ':' + c.getKey())
143+
o.setId(Long.valueOf(f.getLayerPid()))
146144
o.setName(c.getValue().getName())
147145
o.setFid(f.getFieldId())
148146
o.setFieldname(f.getFieldName())
@@ -509,7 +507,7 @@ class SpatialObjectsService {
509507
l = new ArrayList<SpatialObjects>()
510508
IntersectionFile f = layerService.getIntersectionFile(fid)
511509
if (f != null && f.getClasses() != null) {
512-
Vector v = layerIntersectDao.samplingFull(fid, lng, lat)
510+
Vector v = layerIntersectService.samplingFull(fid, lng, lat)
513511
if (v != null && v.size() > 0 && v.get(0) != null) {
514512
Map m = (Map) v.get(0)
515513
int key = (int) Double.parseDouble(((String) m.get("pid")).split(':')[1])
@@ -669,7 +667,7 @@ class SpatialObjectsService {
669667
}
670668

671669
// sampling
672-
ArrayList<String> sample = layerIntersectDao.sampling(new String[]{layerFilter.getLayername()}, points)
670+
ArrayList<String> sample = layerIntersectService.sampling(new String[]{layerFilter.getLayername()}, points)
673671

674672
// filter
675673
List<SpatialObjects> matched = new ArrayList<SpatialObjects>()

grails-app/views/layer/show.gsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%@ page contentType="text/html;charset=UTF-8" %>
1+
<%@ page import="java.nio.charset.StandardCharsets" contentType="text/html;charset=UTF-8" %>
22
<html>
33
<head>
44
<title>${layer.displayname}</title>
@@ -129,7 +129,7 @@
129129
<tr>
130130
<td>Download</td>
131131
<td><a class="btn btn-default"
132-
href="${spatialConfig.grails.serverURL}/layer/download/${URLEncoder.encode(layer.displayname)}.zip">
132+
href="${spatialConfig.grails.serverURL}/layer/download/${URLEncoder.encode(layer.displayname, java.nio.charset.StandardCharsets.UTF_8).replace("+", "%20")}.zip">
133133
<i class="glyphicon glyphicon-download"></i>
134134
${layer.displayname}.zip</a>
135135
</td>

src/main/groovy/au/org/ala/spatial/process/AooEoo.groovy

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class AooEoo extends SlaveProcess {
102102

103103
//concave hull
104104
taskLog("calculating concave hull")
105-
Geometry concaveHull = buildConcaveHull(g, alpha)
105+
Geometry concaveHull = buildConcaveHull(g, alpha, this)
106106
Double alphaHull = null
107107
String concaveWkt = null
108108
if (concaveHull == null) {
@@ -305,35 +305,41 @@ class AooEoo extends SlaveProcess {
305305
* @param alpha
306306
* @return
307307
*/
308-
static Geometry buildConcaveHull(Geometry geometry, Double alpha) {
308+
static Geometry buildConcaveHull(Geometry geometry, double alpha, AooEoo object) {
309309
DelaunayTriangulationBuilder triangulation = new DelaunayTriangulationBuilder()
310310
triangulation.setSites(geometry)
311311
Geometry triangles = triangulation.getTriangles(new GeometryFactory())
312312
Geometry edges = triangulation.getEdges(new GeometryFactory())
313313

314314
//get mean edge length
315-
int sum = 0
315+
double sum = 0
316316
for (int i = 0; i < edges.numGeometries; i++) {
317-
sum += (int) edges.getGeometryN(i).length
317+
sum += new LineSegment(edges.getGeometryN(i).getCoordinates()[0], edges.getGeometryN(i).getCoordinates()[1]).length
318318
}
319-
double meanByAlpha = sum / (edges.numGeometries * alpha)
319+
320+
double meanLength = sum / (double) edges.numGeometries
321+
double threshold = meanLength * alpha
320322

321323
//remove triangles with at least one edge length > meanByAlpha
322324
Geometry union = null
325+
int included = 0
323326
for (int i = 0; i < triangles.numGeometries; i++) {
324327
Geometry triangle = triangles.getGeometryN(i)
325328
boolean valid = true
326329
for (int j = 1; j < 3 && valid; j++) {
327-
if (new LineSegment(triangle.coordinates[j], triangle.coordinates[j - 1]).length > meanByAlpha) {
330+
if (new LineSegment(triangle.coordinates[j], triangle.coordinates[j - 1]).length > threshold) {
328331
valid = false
329332
}
330333
}
331334
if (valid) {
335+
included++
332336
if (union == null) union = triangle
333337
else union = union.union(triangle)
334338
}
335339
}
336340

341+
object.taskLog("Concave hull; included " + included + " triangles out of " + triangles.numGeometries)
342+
337343
//return geometry
338344
return union
339345
}

src/main/groovy/au/org/ala/spatial/process/SlaveProcess.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class SlaveProcess {
425425

426426
Integer facetCount(String facet, SpeciesInput species, String extraFq) {
427427
String fq = ''
428-
if (extraFq) fq = '&fq=' + URLEncoder.encode(extraFq, StandardCharsets.UTF_8)
428+
if (extraFq) fq = '&fq=' + URLEncoder.encode(extraFq, StandardCharsets.UTF_8).replace("+", "%20")
429429

430430
String url = species.bs + "/occurrence/facets?facets=" + facet + "&flimit=0&q=" + joinSpeciesQ(species.q) + fq
431431
try {
@@ -448,7 +448,7 @@ class SlaveProcess {
448448

449449
Integer occurrenceCount(SpeciesInput species, String extraFq) {
450450
String fq = ''
451-
if (extraFq) fq = '&fq=' + URLEncoder.encode(extraFq, StandardCharsets.UTF_8)
451+
if (extraFq) fq = '&fq=' + URLEncoder.encode(extraFq, StandardCharsets.UTF_8).replace("+", "%20")
452452

453453
String url = species.bs + "/occurrences/search?&facet=off&pageSize=0&q=" + joinSpeciesQ(species.q) + fq
454454
String response = Util.getUrl(url)
@@ -1094,7 +1094,7 @@ class SlaveProcess {
10941094

10951095
try {
10961096
String fq = ''
1097-
if (extraFq) fq = '&fq=' + URLEncoder.encode(extraFq, StandardCharsets.UTF_8)
1097+
if (extraFq) fq = '&fq=' + URLEncoder.encode(extraFq, StandardCharsets.UTF_8).replace("+", "%20")
10981098
String url = species.bs + "/occurrences/facets/download?facets=names_and_lsid&lookup=" + lookup + "&count=" + count + "&q=" + joinSpeciesQ(species.q) + fq
10991099
taskLog("Loading species ...")
11001100
log.debug("Loading species from: " + url)

src/main/groovy/au/org/ala/spatial/util/AreaReportPDF.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class AreaReportPDF {
331331
if (fq == null) {
332332
return query
333333
} else {
334-
return query + "&fq=" + URLEncoder.encode(fq, StandardCharsets.UTF_8)
334+
return query + "&fq=" + URLEncoder.encode(fq, StandardCharsets.UTF_8).replace("+", "%20")
335335
}
336336
}
337337

src/main/groovy/au/org/ala/spatial/util/OccurrenceData.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class OccurrenceData {
2424

2525
//add to 'identified' sensitive list
2626
try {
27-
CSVReader csv = new CSVReader(new StringReader(getSpecies(q + "&fq=" + URLEncoder.encode("-sensitive:[* TO *]", StandardCharsets.UTF_8), bs)))
27+
CSVReader csv = new CSVReader(new StringReader(getSpecies(q + "&fq=" + URLEncoder.encode("-sensitive:[* TO *]", StandardCharsets.UTF_8).replace("+", "%20"), bs)))
2828
List<String[]> fullSpeciesList = csv.readAll()
2929
csv.close()
3030
for (int i = 0; i < fullSpeciesList.size(); i++) {
@@ -36,7 +36,7 @@ class OccurrenceData {
3636

3737
//remove sensitive records that will not be LSID matched
3838
try {
39-
Records r = new Records(bs, q + "&fq=" + URLEncoder.encode("-sensitive:[* TO *]", "utf-8"), null, records_filename, null, facetName)
39+
Records r = new Records(bs, q + "&fq=" + URLEncoder.encode("-sensitive:[* TO *]", "utf-8").replace("+", "%20"), null, records_filename, null, facetName)
4040

4141
StringBuilder sb = null
4242
if (r.getRecordsSize() > 0) {

src/main/groovy/au/org/ala/spatial/util/PrintMapComposer.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ class PrintMapComposer {
666666
for (String param : params.split("&")) {
667667
int eq = param.indexOf('=')
668668
if (eq > 0) {
669-
u += "&" + param.substring(0, eq + 1) + URLEncoder.encode(param.substring(eq + 1), StandardCharsets.UTF_8)
669+
u += "&" + param.substring(0, eq + 1) + URLEncoder.encode(param.substring(eq + 1), StandardCharsets.UTF_8).replace("+", "%20")
670670
}
671671
}
672672

0 commit comments

Comments
 (0)