@@ -480,113 +480,6 @@ <h1>Sample Leaflet Map with Elasticsearch</h1>
480
480
$ ( '#modal' ) . remove ( ) ;
481
481
}
482
482
483
- function getFeatureData ( scroll_id ) {
484
-
485
- var b = map . getBounds ( ) ,
486
- b1 = {
487
- "tllat" : b . getNorthWest ( ) . lat > 90 ? 90 : b . getNorthWest ( ) . lat ,
488
- "tllon" : b . getNorthWest ( ) . lng < - 180 ? - 180 : b . getNorthWest ( ) . lng ,
489
- "brlat" : b . getSouthEast ( ) . lat < - 90 ? - 90 : b . getSouthEast ( ) . lat ,
490
- "brlon" : b . getSouthEast ( ) . lng > 180 ? 180 : b . getSouthEast ( ) . lng
491
- } , scroll_id ;
492
-
493
- // bounding box query
494
- var feature_query = {
495
- "size" : 1000 ,
496
- "_source" : [ "id" , "type" , "geometry.*" , "properties." + feature_index_prop ] ,
497
- "query" : {
498
- "geo_shape" : {
499
- "geometry" : {
500
- "shape" : {
501
- "type" : "envelope" ,
502
- "coordinates" : [ [ b1 . tllon , b1 . tllat ] , [ b1 . brlon , b1 . brlat ] ]
503
- } ,
504
- "relation" : "intersects"
505
- }
506
- }
507
- }
508
- }
509
-
510
- // range query
511
- // var d = {
512
- // "query": {
513
- // "range": {
514
- // "properties.sH_PGA": {
515
- // "gte": 0.047580,
516
- // "lte": 0.047584
517
- // }
518
- // }
519
- // }
520
- // };
521
-
522
- // return all query
523
- // var feature_query = {
524
- // "size": "1000",
525
- // "query": {
526
- // "bool": {
527
- // "must": {
528
- // "match_all": {}
529
- // }
530
- // }
531
- // }
532
- // };
533
-
534
- if ( scroll_id ) {
535
- feature_query = {
536
- "scroll" : "1m" ,
537
- "scroll_id" : scroll_id
538
- }
539
- }
540
-
541
- var feature_url = scroll_id ?
542
- "https://api.stage.riskprofiler.ca/_search/scroll"
543
- : "https://api.stage.riskprofiler.ca/" + feature_index + "/_search?scroll=1m" ;
544
-
545
- // Get Feature data
546
-
547
- $ . ajax ( {
548
- method : "POST" ,
549
- tryCount : 0 ,
550
- retryLimit : 3 ,
551
- crossDomain : true ,
552
- url : feature_url ,
553
- data : JSON . stringify ( feature_query ) ,
554
- headers : { "content-type" : "application/json" }
555
- } )
556
- . done ( function ( resp ) {
557
-
558
- var len = geojsonLayer . getLayers ( ) . length ;
559
-
560
- if ( len === resp . hits . total . value || len === featureLimit ) {
561
- $ ( '#modal' ) . remove ( ) ;
562
- }
563
-
564
- if ( len < resp . hits . total . value && len < featureLimit ) {
565
- addGeoJSONFeatures ( resp . hits . hits , function ( e ) {
566
- if ( resp . hits . hits . length > 0 && len <= featureLimit ) {
567
- getFeatureData ( resp . _scroll_id ) ;
568
- }
569
- if ( geojsonLayer . getLayers ( ) . length >= featureLimit ) {
570
- $ ( '#alert' ) . show ( ) ;
571
- }
572
- } ) ;
573
- }
574
-
575
-
576
- } )
577
- . fail ( function ( error ) {
578
- this . tryCount ++ ;
579
- if ( this . tryCount <= this . retryLimit ) {
580
- //try again
581
- $ . ajax ( this ) ;
582
- return ;
583
- }
584
- console . log ( "Doh! " + error )
585
- return ;
586
-
587
- } ) ;
588
- }
589
-
590
483
// tile to lat lon calculations
591
484
// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Implementations
592
485
0 commit comments