Skip to content

Commit

Permalink
api: added json response option for /annotation/index
Browse files Browse the repository at this point in the history
  • Loading branch information
iSkore committed Jan 11, 2019
1 parent b34e32b commit 7344fbb
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ docker-compose up tlv
```

6. Navigate to [`http://localhost:8080`](http://localhost:8080)

7. Editing in development mode:
```
cd $O2_DEV_HOME/tlv/apps/tlv-app
grails run-app
```
41 changes: 39 additions & 2 deletions apps/tlv-app/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseUrl: https://omar.ossim.io
baseUrl: https://omar-dev.ossim.io
geocoderUrl: ${baseUrl}/omar-ui/twoFishesProxy

libraries:
Expand All @@ -17,7 +17,7 @@ environments:
driverClassName: org.postgresql.Driver
username: postgres
password: postgres
url: jdbc:postgresql://postgis:5432/tlv
url: jdbc:postgresql://0.0.0.0:5432/tlv

---
defaultUsername: Anonymous
Expand Down Expand Up @@ -74,3 +74,40 @@ grails:
filters: 'none'
- pattern: '/**'
filters: 'JOINED_FILTERS'

---
#layers:
# countries:
# label: Country Borders
# url: ${baseUrl}/omar-wfs/wfs/getFeature
# params:
# maxFeatures: 1000
# outputFormat: JSON
# request: GetFeature
# service: WFS
# typeName: omar:country_border
# version: 1.1.0
# refresh: false
# style:
# text:
# attribute: name
# color: white
# o2-wfs:
# label: O2 WFS
# url: ${baseUrl}/omar-wfs/wfs/getFeature
# params:
# filter: BBOX(ground_geom,<BBOX>)
# maxFeatures: 1000
# outputFormat: JSON
# request: GetFeature
# service: WFS
# sortBy: acquisition_date+D
# typeName: omar:raster_entry
# version: 1.1.0
# refresh: true
# style:
# stroke:
# color: black
# text:
# color: black
# label: image_id
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function saveAnnotations() {
};
var link = location.protocol + "//" + location.host + tlv.contextPath + "?" + $.param( urlParams )

if ( geometry.getType() == "Circle" ) {
if ( geometry.getType() === "Circle" ) {
geometry = new ol.geom.Polygon.fromCircle( geometry, 100 );
}
var properties = feature.getProperties();
Expand Down Expand Up @@ -482,7 +482,7 @@ function saveAnnotations() {
displayDialog( "dragoDialog" );
})
.fail( function() {});
}
};

var mapCenter = tlv.map.getView().getCenter();
getDtedHeight( mapCenter[ 1 ], mapCenter[ 0 ], callback );
Expand All @@ -508,8 +508,12 @@ function saveAnnotations() {
}

function searchForAnnotations() {
console.log( 'searchForAnnotations' );

$.each( tlv.layers, function( index, layer ) {
if ( !layer.annotations ) {
console.log( layer );

var params = {
filter: "image_id LIKE '" + layer.imageId + "'",
maxResults: 100,
Expand All @@ -519,10 +523,11 @@ function searchForAnnotations() {
typeName: "omar:annotation",
version: "1.1.0"
};
$.ajax({

$.ajax( {
url: tlv.libraries[ layer.library ].wfsUrl + "?" + $.param( params )
})
.done(function( data ) {
} )
.done( function( data ) {
layer.annotations = data;
if ( data.features.length > 0 ) {
addAnnotations( data, layer );
Expand Down Expand Up @@ -562,7 +567,8 @@ function bindWindowUnload() {
var setupTimeLapseAnnotations = setupTimeLapse;
setupTimeLapse = function() {
setupTimeLapseAnnotations();
//searchForAnnotations();

searchForAnnotations();

bindWindowUnload();
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AnnotationController {

def annotationService

Writer expressionOut = getExpressionOut()

def export() {
def results = Annotation.list( params ).unique { annotation -> annotation.geometryOrtho }
Expand All @@ -30,8 +31,11 @@ class AnnotationController {
params.max = Math.min(max ?: 10, 10000)
def results = Annotation.list( params ).unique { annotation -> annotation.geometryOrtho }


respond results, model:[ annotationCount: Annotation.count() ]
if( request.getHeader( "content-type" ) == "application/json" ) {
render new JSON( results )
} else {
respond results, model:[ annotationCount: Annotation.count() ]
}
}

def saveAnnotation() {
Expand Down
33 changes: 33 additions & 0 deletions apps/tlv-app/test.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "Feature",
"bbox": [
-95.509195,
29.614226,
-95.520448,
29.607519
],
"properties": {
"latlng": "29.6191, -95.5371"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ -95.509195, 29.614226 ],
[ -95.520448, 29.614226 ],
[ -95.520448, 29.607519 ],
[ -95.509195, 29.607519 ],
[ -95.509195, 29.614226 ]
]
],
"style": {
"fill": "red",
"stroke": "black",
"stroke-width": "3",
"fill-opacity": 0.6
},
"className": {
"baseVal":"highway_primary"
}
}
}

0 comments on commit 7344fbb

Please sign in to comment.