Skip to content

Commit

Permalink
Updated getSimpleProjectArea to set site geoIndex, refactored SciStar…
Browse files Browse the repository at this point in the history
…t project import @schedule tag to be a job
  • Loading branch information
jack-brinkman committed Sep 19, 2024
1 parent 72d129b commit a01f83b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
20 changes: 20 additions & 0 deletions grails-app/jobs/au/org/ala/ecodata/ImportSciStarterJob.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package au.org.ala.ecodata

import grails.core.GrailsApplication

class ImportSciStarterJob {

GrailsApplication grailsApplication
ProjectService projectService

static triggers = {
Boolean enabled = grailsApplication.config.getProperty("sciStarter.importEnabled", Boolean, true)
if (enabled) {
cron name: "every sunday", cronExpression: "0 0 * * 0"
}
}

def execute() {
projectService.importProjectsFromSciStarter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ class ProjectService {
* And link artifacts to the project. TODO: creating project extent.
* @return
*/
@Scheduled(cron = "0 0 * * 0")
Map importProjectsFromSciStarter() {
int ignoredProjects = 0, createdProjects = 0, updatedProjects = 0, page = 1
JsonSlurper slurper = new JsonSlurper()
Expand Down
8 changes: 4 additions & 4 deletions grails-app/services/au/org/ala/ecodata/SiteService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ class SiteService {
}

def getSimpleProjectArea(projectSiteId) {
def threshold = grailsApplication.config.getProperty('biocollect.projectArea.simplificationThreshold')
def tolerance = grailsApplication.config.getProperty('biocollect.projectArea.simplificationTolerance')
def threshold = grailsApplication.config.getProperty('biocollect.projectArea.simplificationThreshold', 10000)
def tolerance = grailsApplication.config.getProperty('biocollect.projectArea.simplificationTolerance', 0.1)
log.info("Threshhold ${threshold} Tolerance ${tolerance}")

def site = get(projectSiteId, [SiteService.FLAT, SiteService.INDEXING])
Expand All @@ -268,9 +268,9 @@ class SiteService {
if (projectArea?.coordinates != null) {
def coordsSize = projectArea.coordinates.flatten().size()
if (coordsSize > threshold) {
GeometryUtils.simplify(projectArea, tolerance)
site.geoIndex = GeometryUtils.simplify(projectArea, tolerance)
} else {
projectArea
site.geoIndex = projectArea
}
}
}
Expand Down

0 comments on commit a01f83b

Please sign in to comment.