Home

RodasRivera2014_PartII

image

Contents

1. Expands a cluster starting from the specified photo and its neighbours param cluster cluster Cluster to expand param photo Spoint First photo in the cluster param photo neighbours Neighbours of the first photo return cluster rd private function expand cluster cluster cluster photo point array neighbours Add photo to cluster cluster add point Mark it as visited and part of a cluster S this visited point getId IN CLUSTER i 0 Loop through the list of neighbours while i lt count Sneighbours By default mark photo as density reachable Sdensity_reachable TRUE Get current neighbour Scurrent neighbours i Check if photo has been visited Sstatus array key exists current 5getId this gt visited Tf it has not been visited it lSstatus 1 Retrieve the neigbours of the current photo Scurrent neighbors current getNeighbors S this gt eps Sthis gt tag Sthis min accuracy S this geom S this from Sthis to If the number of neighbours is greater or equal to the minimum number of photos if count S current neighbors gt S this min pts Add its neigbours to the list of neigbours Sneighbours this merge neighbours current neighbors Mark it as core point Sdensity_reachable FALSE else Else retrieve its visited status Sstatus S this visited current 5getId
2. lt l Author Juan Luis Rodas Rivera Copyright c 2014 Juan Luis Rodas Rivera and The University of Edinburgh gt lt html lang en gt lt head gt lt meta charset utf 8 gt meta http equiv X UA Compatible content IE edge meta name viewport content width device width initial scale i1 7 gt lt title gt Study Area Explorer Tempo spatial explorer of Flickr tags lt title gt lt link rel icon type image png href img map png gt lt link rel stylesheet href http ol3js org en master css ol css type text css gt lt link rel stylesheet href css bootstrap css type text css gt lt link rel stylesheet href css bootstrap theme css type text css gt lt link rel stylesheet href css viewer css type text css I script src http ol3js org en master build ol js type text javascript script script src js ol whitespace js type text javascript gt lt script gt soript src js jquery 2 1 1 js type text javascript gt lt script gt script src js bootstrap js type text javascript gt lt script gt lt head gt lt body gt lt Navigation bar gt lt div id navbar class navbar navbar default navbar fixed top role navigation gt lt div class container gt lt div class navbar header gt button type button class navbar toggle data toggle collapse data target navbar collapse spa
3. th class text right gt lt th gt lt th gt Tag lt th gt lt th class text right gt Photos lt th gt lt th class text right Last update lt th gt lt th gt Update lt th gt lt th gt Reduced lt th gt lt th class text right gt No reduced lt th gt lt th gt Download dataset lt th gt lt th gt Delete lt th gt eitr thead tbody php Sgeoserver GEOSERVER Sconn pg_connect CONN_STRING Retrieve list of tags Sresultl pg query conn SELECT FROM photo summary ORDER BY name if pg num rows resultl 0 echo tr td class text right lt td gt lt td gt Empty lt td gt lt td class text right td td class text right td td td td td td class text right td td td td td tr PHP EOI else Populate list while row pg fetch row resultl Sreduced No n reduced lt button type button class btn btn sm btn default btn block data loading text Please wait onclick reduce_data row 0 gt lt span class glyphicon glyphicon screenshot gt lt span gt Reduce lt button gt lt span gt lt span gt 61 Juan Luis Rodas Rivera Technical Report Check if photos for this tag have been reduced if Srow 4 1 Sreduced Yes Assign number of reduced photos if Srow 4 Srow 2 0 Sn_reduced lt button type button class btn btn sm btn default btn
4. Figure 5 Study area entity and its attributes 5 1 5 Cluster entity The final entity defined for the application is the cluster A cluster is tied to a study area and has a spatial extent and a sequential number that describes to which of the time units of the study area it belongs The cluster entity and its attributes are shown on Figure 6 Time unit sequential c Cluster Spatial extent Figure 6 Cluster entity and its attributes Juan Luis Rodas Rivera Technical Report 5 2 Relationships There are many relationships between the entities defined in the previous section The photo entity has three many to many relationships one with the tag entity one with the data grab entity and one with the cluster entity Photos on Flickr can have multiple tags associated with them and conversely a tag can be applied to multiple photos A data grab involves the download of multiple photos and a photo can be involved in multiple data downloads if for example the data for the photo is being downloaded for a different tag that the one that already exists on the database A photo can also be included in many clusters for different study areas and every cluster includes as an absolute minimum two points The tag entity has two one to many relationships besides the many to many relationship defined above one with the data grab entity and one with the study area entity Photos for a tag can be downloaded in more tha
5. This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt require_once include vars php require_once include study_area php Script in charge of getting the number of photos in a study area and time unit copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera 4 Retrieve parameters study area and sequential sa new study area htmlspecialchars POST sa Sseq htmlspecialchars _POST seq Return the number of photos in JSON format header Content Type application json echo json encode count gt sa getNumPhotos seq JSON PRETTY PRINT die 103 Juan Luis Rodas Rivera Technical Report ww_poll_tag_update php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY w
6. F F HF x You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt xy require_once dirname __FILE__ vars php require_once dirname __FILE__ tag php require_once dirname __FILE__ dbscan algorithm php require_once dirname __FILE__ geoPHP geoPHP inc Class that represents a study area defined by the user copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera Ef class study_area The unique identifier of the study area var integer 2y private id The tag asociated to the study area var tag oy private Stag The textual description of the study area var string Kr private Sdescription Whether the description needs update var boolean private Supd_description false The quadrat size used in the study area 132 Juan Luis Rodas Rivera Technical Report var real x private quadrat_size Whether the quadrat size needs update var boolean private S upd quadrat size false The minimal accuracy for photos in the study area var integer sy private min accuracy Whether the minimal accuracy needs update var boolean private S upd min accuracy false The search radius for neighbours on the DBSCAN algorithm
7. If the point has not been visited and is not in a cluster add it to this cluster and mark it as in a cluster if status IN CLUSTER 123 Juan Luis Rodas Rivera Technical Report Sthis gt visited Scurrent gt getId IN CLUSTER Scluster gt add Scurrent S density reachable Sitt return Scluster Merges to list of photos together param photo seeds List of photos to which to add x param photo neighbors List of photos to add return photo ey private function merge seeds neighbors Loop through the list of photos to add foreach neighbors as neighbor If a photo is not already in the list add it if in_array Sneighbor Sseeds array_push S seeds S neighbor return Sseeds Stores the clusters in the database param integer Sid The identifier of the study area param integer seq The sequential to which the cluster belongs aA function store Sid Sseq Loop through each cluster and store it foreach S this gt clusters as cluster Scluster gt store Sid seq S this eps 124 Juan Luis Rodas Rivera Technical Report footer php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later versio
8. param integer study_area The unique identifier of the study area function calculate_clusters study_area Get cell that called the action var caller_cl cl_ study_area Get button that called the action var btn caller cl find button Set button to loading state btn button loading Initiate AJAX request to calculate clusters of this study area S post action ww_clusters php study_area study_area When done done function data Update list of study areas with data returned S data caller text data num Reset button state btn button reset Hide button btn addClass hidden json Sets POST parameters for the viewer and submits the form param integer sa id The unique identifier to send param string action Mode in which the viewer will be initialised a function goToViewer sa_id action Set identifier S sa_id val sa_id Set mode sa_mode val action Submit form fsa action submit Go to viewer on explore mod param integer sa id The unique identifier of the study area uu function explore sa id Send identifier of the study area goToViewer sa id explore Go to viewer on edit mode param integer sa id The unique identifier of the study area og function edit sa id Send identifier of the study area goToViewer sa id edit Go to viewer on
9. x window load function Add layers addLayers true If mode is explore set initial time slider colour if mode explore setSliderColours 0 Technical Report 94 Juan Luis Rodas Rivera Technical Report Appendix E CSS code for the main web pages index css This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt x Styling for index php i Author Juan Luis Rodas Rivera 2 Copyright c 2014 Juan Luis Rodas Rivera and The University of Edinburgh body padding top 50px position relative 95 Juan Luis Rodas Rivera Technical Report viewer css This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the
10. S max area FROM cluster a cluster b WHERE ST Intersects a geom b geom AND a study area id sa AND a id cluster AND b study_area_id sa result pg query conn sql Place them in the results array while Srow pg_fetch_row Sresult array push return array Srow 0 S row 1 Retrieve cluster which overlap across time units elseif array key exists seq S_POST Retrieve sequential Sseq htmlspecialchars POST seqg 101 Juan Luis Rodas Rivera Technical Report Loop from two time units before to time units past the sequential for i 2 i lt 2 i Skip current time unit if i 0 Retrieve overlaping clusters Ssql SELECT FROM clusters_overlap sa seq 1 result pg query conn sql Place them in the results array if pg fetch result result 0 0 1 array push S return i pg_close Sconn Return the clusters that overlap in JSON format header Content Type application json echo json_encode return JSON PRETTY PRINT die 102 Juan Luis Rodas Rivera Technical Report ww_photo_count php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version
11. Set the background colours on the time slider param integer seq Sequential of the time unit f function setSliderColours seq Remove existing colours and add colour to present time unit S fkseq area 0 parent children removeClass S seq_area_ seq addClass selected S seq_count_0 parent children removeClass j S seq_count_ seq addClass selected Send AJAX request to find out if there are overlapping clusters on neighbouring time units post action ww_overlaping_clusters php sa id seq seq done function data for var i in data Add colour class depending on time differential switch data i case 2 4seq area seq prev prev addClass minus2 seq_ count seq prev prev addClass minus2 break case 1 S seq_area_ seq prev addClass minus1 S f seq count seq prev addClass minus1 break case 1 4seq area seq next addClass plus1 87 Juan Luis Rodas Rivera Technical Report S seq_count_ seq next addClass plusl1 break case 2 seq_area_ seq next next addClass plus2 S seq_count_ seq next next addClass plus2 break be 390m Set the photo count for a time unit param integer seq Sequential of the time unit y function setPhotoCount seq Send AJAX request to find out the number of photos on a time unit
12. return integer public function getMinPoints return S this min pts Returns the list of clusters found return cluster public function getClusters return Sthis clusters Returns the number of clusters found return integer ki 121 Juan Luis Rodas Rivera Technical Report public function getNumClusters return count this gt clusters Class constructor param tag Stag Tag for which the clusters are being calculated param integer min accuracy Minimum accuracy of the points on the calculation param string geom WKT geometry of the study area param string from Lower boundary of the timeframe param string Sto Upper boundary of the timeframe param real Seps Search distance param integer min pts Minimum number of points to define a cluster E function __construct Stag min accuracy Sgeom Sfrom Sto Seps Smin_pts Assign initial values Sthis gt tag tag Sthis gt min_accuracy min accuracy Sthis gt geom geom Sthis gt from Sfrom Sthis gt to Sto Sthis gt eps Seps Sthis gt min_pts min pts Sthis gt points array Sthis clusters array Sthis gt visited array Retrieve the list of photos that meet the search criteria sql SELECT FROM photo reduced WHERE tag id tag getId AND accuracy gt S this min accuracy AND date taken BETWEEN this gt from
13. GROUP BY study area id seg View that presents all the data for the reduced photo dataset CREATE OR REPLACE VIEW photo reduced AS SELECT a id a num a date added a date taken a accuracy a usr a lat a lon a farm a server a secret a geom c tag id d name AS tag FROM photo a INNER JOIN filtered photo b ON a id b id INNER JOIN photo tag c ON a id c photo id INNER JOIN tag d ON c tag id d id 51 Juan Luis Rodas Rivera Technical Report View that summarises number of photos per tag used in the application s main page CREATE OR REPLACE VIEW photo summary AS SELECT a id a name COUNT c photo id b started b reduced b count AS num reduced FROM tag a LEFT OUTER JOIN SELECT a tag id a started a reduced COUNT c id AS count FROM data grab a INNER JOIN photo tag b ON a tag id b tag id LEFT OUTER JOIN filtered photo c ON b photo id c id WHERE a latest 1 GROUP BY a tag id a started a reduced b ON a id b tag id LEFT OUTER JOIN photo_tag c ON a id c tag_id GROUP BY a id a name b started b reduced b count View that summarises data for the study areas used in the application s main page CREATE OR REPLACE VIEW study area summary AS SELECT a id a description a tag id b name a quadrat size a min accuracy a eps a min pts a time unit a time units a timeframe from date a timeframe to date a updated CASE WHEN a calculated 0 THEN 1 ELSE COALESCE c count 0 END AS clusters FROM s
14. geom val 0 val 1 geom geom substr 0 geom length 2 Set geometry field in form 4sa geom val geom Submit form S add_study_area submit else Show message if fields have not been filled alert Please fill all fields in the form Shows the quadrat count analysis dialogue aif function quadrat counts Send AJAX request to retrieve quadrat count analysis tables S post action ww quadrat counts php sa id seq parseInt fseq val When done done function data Set quadrat count analysis results on container document getElementById qc container innerHTML data Show quadrat count analysis fquadrat count modal json Popup container for photo preview type exp document call getElementByld ix d var container document getElementById popup Popup content for photo preview Qtype exp document call getElementBylId var content document getElementById popup content 91 Juan Luis Rodas Rivera Technical Report Popup closer for photo preview type exp document call getElementBylId var closer document getElementById popup closer Hide photo preview container on closer click aZ closer onclick function container style display none Overlay to display photo preview type ol Overlay 7 var overla
15. quadrat size 14 Juan Luis Rodas Rivera Technical Report if Sthis gt upd_time_unit Ssql sql time unit this gt time_unit if Sthis upd time units Ssql sql time units this time units if Sthis upd from Ssql sql timeframe from this gt from if Sthis upd from or this upd time unit or S this upd time units agis id this gt id 2id sql sql timeframe to this gt to Sconn pg connect CONN STRING Check if clusters need to be recalculated if S Sthis needsClusterDeletion pg_delete Sconn cluster study area id gt this sql sql updated now calculated 0 WHERE else sql sql updated now WHERE id Sthis Perform the update pg_query S conn sql pg close conn Perform cluster calculation on the study area and return the number of clusters found return integer AY function calculate Retrieve timeframe parameters Sfrom Sthis getFrom Sinterval S this getInterval Retrieve study area hexagonal grid boundary Sgeom S this getQuadratGeom n 0 Loop through each time unit for i 0 i lt Sthis gt time_units i Define upper boundary of the time unit Sto clone Sfrom Sto gt add Sinterval to sub DateInterval createFromDateStrin
16. setTimeUnits S time units int setTo store update Figure 14 Class diagram for study_area class 29 Juan Luis Rodas Rivera Technical Report 8 GeoServer layers GeoServer is the spatial web server used by the application to host the WMS and WFS web services used by the viewer Six web services are defined on GeoServer to be consumed by the tool The cluster_neighbours layer is an SQL view defined on GeoServer that publishes the clusters found on a study area It requires two parameters the identifier of the study area and the time unit for which to retrieve the clusters It returns two attributes the identifier of the cluster and the time difference of the cluster to the current time unit The geometry type is Polygon The photo layer is also an SQL view defined on GeoServer that publishes the non reduced set of photos with tag information It does not require any parameters It returns 14 parameters which are all the parameters from the photo table plus the tag identifier and the tag name associated to a photo The geometry type is Point The photo_reduced layer publishes the view with the same name on the database It returns the same parameters and has the same geometry type as the photo layer but for the reduced dataset of photos The quadrat count layer is an SQL view defined on GeoServer that publishes the quadrats on a study area It requires two parameters the identifier of the study area and t
17. var real private Seps Whether the eps parameter needs update var boolean m private S upd eps false The minumum number of points to create a cluster on the DBSCAN algorithm var integer cu private min pts Whether the min pts parameter needs update var boolean ay private Supd_min_pts false The time unit used on the study area var string private S time unit Whether the time unit needs update var boolean private S upd time unit false The number of time units in the study area 133 Juan Luis Rodas Rivera Technical Report var integer kd private time units Whether the number of time units needs update var boolean x private S upd time units false The staring date of the timeframe var string y private from Whether the starting date of the timefrme needs update var boolean 4 private upd from false The ending date of the timefram var string private to Whether clusters in the study area have been calculated var integer private calculateg The date of the last update made to the study area var string private Supdated The geometry of the study area var string private Sgeom Whether the geometry needs update var boolean ar private S upd geom false Returns the uniq
18. 0 i lt obj getTimeUnits i echo S obj getFrom i format Y m dXTE izsMZ Sobj 2getTo i 5format Y m dNTH i sWMZ j if Si Sobj gt getTimeUnits 1 acho t T break Boundaries of the timeframe case edit echo obj gt getFrom gt format Y m dXTB 31 8M427 T Sobj Sg etTo Stformat m d THsi s n T break Default boundaries case add echo D 2000 01 01T00 00 00Z2 2100 01 O1TOOSO0 2002 gt break Address of host where geoserver is running type string ud var geoserver php echo GEOSERVER gt i sScelpe script src js viewer js type text javascript gt lt script gt body html 74 Juan Luis Rodas Rivera Technical Report Appendix D JavaScript code for the main web pages index js This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with
19. 50 bigint timestamp smallint bigint Description Identifier of the tag Name of the tag Number of photos for this tag Date and time this tag was last updated Whether photos for this tag have been reduced Number of reduced photos for this tag 6 2 4 View study area summary The view study area summary summarises data for all study areas It is used on the application s main page It has the structure shown on Table 13 Attribute id description tag id name quadrat size min accuracy eps min pts time unit time units timeframe from timeframe to updated Table 13 Structure of view study area summary Data type integer character varying 50 integer character varying 50 real smallint real integer interval integer timestamp timestamp timestamp Description Identifier of the study area Textual description of the study area Identifier of the tag for the study area Name of the tag Size of the quadrats to use in cluster validation Minimum accuracy of the photos Search radius for neighbours Minimum number of points to define a cluster Time unit of the timeframe Number of time units in the timeframe Lower boundary of the timeframe Upper boundary of the timeframe Date and time of last update to the study area 22 Juan Luis Rodas Rivera Technical Report clusters bigint Number of cluster found in the study area 6 2 5 View photos on study area The view study area summ
20. AND S this 5to AND ST Within geom S this geom Sconn pg connect CONN STRING result pg query conn sql Add them to the photo list while row pg fetch row result array push this points new photo row 1 Srow 2 row 3 row 4 row 5 row 6 Srow 7 Srow 8 Srow 9 row 10 row 0 pg close conn Search for clusters in the list of photos f function find clusters If there are less photos than the minimum then return if count S this points lt this min pts return Loop through the list of photos for Si 0 i lt count Sthis gt points Sitt Retrieve current photo Spoint S this points i If this photo has been visited already then skip to next photo if array key exists point getId Sthis gt visited continue 122 Juan Luis Rodas Rivera Technical Report Get the neighbour of this photo Sneighbours Spoint gt getNeighbors Sthis gt eps Sthis gt tag Sthis gt min_accuracy S this gt geom Sthis gt from Sthis gt to If the number of neighbours is greater or equal to the minimum number of photos then create a new cluster and expand it if count Sneighbours gt this min pts array_push S this gt clusters S this expand cluster new cluster S point Sneighbours else Else mark photo as visited and noise S this visited point getId NOISE
21. Accessed 11 Jun 2014 PostGIS Development Group 2014a PostGIS Installation online Available at lt http www postgis net install gt Accessed 16 Jun 2014 PostGIS Development Group 2014b PostGIS Home online Available at lt http postgis refractions net gt Accessed 16 Jun 2014 PostgreSQL Global Development Group 2014a PostgreSQL Documentation 9 3 Numeric Types online Available at http www postgresql org docs 9 3 static datatype numeric html Accessed 11 Jul 2014 PostgreSQL Global Development Group 2014b PostgreSQL History online Available at lt http www postegresql org about history gt Accessed 14 Jun 2014 Rodas Rivera J L 2014 A tool for exploring the tempo spatial distribution of Flickr tags University of Edinburgh p 31 45 Juan Luis Rodas Rivera Technical Report The GeoServer Project 2014a About GeoServer online Available at lt http www geoserver org about gt Accessed 12 Jun 2014 The GeoServer Project 2014b GeoServer User Manual GeoServer 2 5 x User Manual online Available at lt http docs geoserver org stable en user gt Accessed 20 Jun 2014 The PHP Group 2014 PHP Introduction Manual online Available at lt https www php net manual en oop5 intro php gt Accessed 15 Jun 2014 46 Juan Luis Rodas Rivera Technical Report Appendices 47 Juan Luis Rodas Rivera Technical Report List of Appendices Appen
22. a wkt ax ll ay Il Store WKT of the first point needed to close the polygon IF angle 30 THEN a lst point a x l y IIl END IF END LOOP Add WKT of first point to close the polygon a wkt a wkt a 1st point Create geometry object a quadrat ST GeomFromText a wkt 3857 If hexagon is completely within the study area include it in the results IF ST Within a quadrat fl geom THEN RETURN QUERY SELECT i a quadrat END IF Move to next hexagon a CX 7 a Cx a horiz END LOOP Move to next row a cy a cy a vert Increase row count r r l END LOOP END LOOP END LANGUAGE plpgsql Calculates the number of photos per quadrat CREATE OR REPLACE FUNCTION quadrat_count a_id integer a_seq integer RETURNS TABLE id integer count bigint geom geometry AS DECLARE f1 record Loop each quadrat in the study area tag integer Id of the tag on the study area tf_from timestamp Lower boundary of the timeframe tf_unit interval Time unit tf to timestamp Upper boundary of the timeframe min acc smallint Minimum accuracy BEGIN Retrieve information from the study area to filter the photo dataset 56 Juan Luis Rodas Rivera Technical Report SELECT a tag_id a timeframe_from a time_unit a min_accuracy FROM study_area a WHERE a id a id INTO tag tf from tf unit min acc Calculate the lower and upper boundarie
23. col sm 5 lt input type text name tag id tag_name class form control maxlength 50 required required placeholder Enter the tag to add gt lt div gt lt div gt lt div class form group gt div class col sm offset 1 col sm 5 button type submit class btn btn default gt lt span class glyphicon glyphicon plus gt lt span gt Add lt button gt lt faiv gt lt div gt lt form gt lt div gt lt div gt lt List of study areas section gt lt div id study_areas class panel panel default lt div class panel panel heading lt h2 class panel title gt lt span class glyphicon glyphicon map marker span Current study areas lt h2 gt lt div gt lt div class panel body lt p gt This is the list of study areas defined in the tool for data exploration lt p gt lt form action viewer php method post id sa_action role form gt lt input type hidden name id id sa_id gt lt input type hidden name id2 id sa_id2 gt lt input type hidden name mode id sa_mode i gt lt form gt lt div gt lt table class table table striped table condensed gt lt thead gt ety th class text right gt lt th gt lt th gt Description lt th gt lt th gt Tag lt th gt lt th class text right gt Quadrat size lt th gt lt th class text right Min accuracy lt th gt lt th class text right gt eps lt th gt lt
24. modal span aria hidden true gt amp times lt span gt lt span class sr only gt Close lt span gt lt button gt lt h4 class modal title id modalLabel gt Quadrat count analysis lt h4 gt lt div gt lt div class modal body gt lt div id 2 qc container class panel panel primary gt Results of quadrat count analysis go here lt div gt lt div gt lt div class modal footer 69 Juan Luis Rodas Rivera Technical Report button type button class btn btn default data dismiss modal gt Close lt button gt lt div gt ey aiv dv dave php Print elements specific for each mode switch Smode case add Print study area form with default values printStudyAreaForm 0obj getId echo lt div class form group div class col sm offset 3 col sm 1 button type button class btn btn default onclick store id btn_store disabled disabled gt lt span class glyphicon glyphicon save gt lt span gt Store lt button gt lt div gt echo lt div class col sm 2 button type button class btn btn default onclick 2 clearDrawings span class glyphicon glyphicon trash gt lt span gt Clear drawing lt button gt lt div gt lt div gt lt form gt lt div gt lt div gt PHP EOL break case edit Print study area form with the values from the existing study area printStudyAreaForm 0 0obj getDescription obj getQuadratSiz
25. new ol style Style fill new ol style Fill color Vegqba 255 255 250 0515 stroke new ol style Stroke color xgba tls5 95 211 0 35 Width 1 25 text new ol style Text textAlign center textBaseline hanging 81 Juan Luis Rodas Rivera Technical Report font normal 10px Arial text text fill new ol style Fill color rgba 75 0 130 1 stroke new ol style Stroke color 4ffffff width 1 Wd Add it to style cache qcStyleCache count hasText style Return the style return style Style cache for polygons in the study area layer type array f var saStyleCache Style function for polygons in the study area layer param ol Feature featur param real resolution returns ol style Style f var saStyleFunction function feature resolution Retrieve style from style cache var style saStyleCache 0 If style does not exist create it if style Create new style style new ol style Style stroke new ol style Stroke color 6495ED width 2 1 Add it to style cache saStyleCache 0 style Return the style return style KK KK kk kk Ck Ck Ck CK Kk kk kk Ck Ck A Ck kk kckckckck ck ck ck ck k ck ckck kc kCk ck I ck kc kc kc kc kckokokok ckcckock kk kk Section Map elements Ck Ck KKK KKK KKK KKK KKK KK KKK kk Ck Ck Ck Kk Ck Sk Ck
26. photos if S this gt page gt 16 Sthis gt page 1 S Sthis parms min upload date Slt Srsp Sthis gt api gt ExecuteMethod flickr photos search Sthis parms Sthis gt pages intval rsp xml photos pages Sthis parms page Sthis gt page Retrieves photos from Flickr ud function grab If there are no photos to download then skip calculations and return if this total 0 Sthis gt done return SlastTimestamp 0 Loop though all the pages with photos do Calculate parameters Sthis recalculateParams 1astTimestamp Get photos from Flickr Srsp Sthis gt api gt ExecuteMethod flickr photos search Sthis parms Loop through each photo on this page foreach rsp xml photos photo as Sphoto Get data on the photo 118 Juan Luis Rodas Rivera Technical Report Spht new photo Sphoto id S photo dateupload Sphoto datetaken Sphoto accuracy Sphoto owner Sphoto latitude Sphoto longitude Sphoto farm Sphoto server Sphoto secret Store the photo on the database S pht store this tag Sthis SlastTimestamp intval photo dateupload Sthis gt pagett while S this gt page lt S this pages Store information when finished Sthis gt done Stores information on the database relating the data download once it has finished private funct
27. post action ww_photo_count php sa id seq seq done function data S photo_count text data count json Set layers and display elements when the time unit changes seq change function Add layers addLayers false Get current time unit var seq S this val Display time boundaries of time unit S from text times seq 0 substr 0 19 replace T S to text times seq 1 substr 0 19 replace T Change time slider colours setSliderColours seg Set photo count setPhotoCount seq Resets the bar chart to standard colours y function resetBars Replace each modified bar for a standard bar img overlap each function index this parent append img src img bar png alt bar class bar this remove Changes the current time unit being displayed param integer seq The time unit to move to function move seq Change if different from current time unit 88 Juan Luis Rodas Rivera Technical Report if parseInt seq val parseInt seq Reset bar chart formatting resetBars Change value of current time unit seq val seq Fire time unit change var el document getHlementById seq var ev document createEvent Event ev initEvent change true false el dispatchEvent ev Change the current time unit
28. qcLayer Add select interaction to edit the study area map removelnteraction select select new ol interaction Select layers saLayer map addInteraction select Add modify interaction to edit the study area map removeInteraction modify modify new ol interaction Modify features select getFeatures map addInteraction modify Set listener to update variable when geometry is changed var selected features select getFeatures selected features on add function event var feature event element feature on change function event modified 1 If exploring if mode explore Define and add quadrat count layer map removeLayer qcLayer qcSource new ol source GeoJSON url geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeN ame sde quadrat count amp outputFormat application json amp viewparams id id seq seq H qcLayer new ol layer Vector source qcSource style gqcStyleFunction visible S layer2 is checked H map addLayer qcLayer Define and add cluster layer map removeLayer clusterLayer clusterSource new ol source GeoJSON url geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeN ame sde cluster neighboors amp outputFormat application json amp viewparams id id seq seq clusterLayer new
29. text id del_id text 78 Juan Luis Rodas Rivera Technical Report viewer js This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see http www gnu org licenses amp Scripting for viewer php 5 Author Juan Luis Rodas Rivera x Copyright c 2014 Juan Luis Rodas Rivera and The University of Edinburgh j J RCKCKCKCK KCKCK kk kCKCKCk KC Ck kCKCK CK ee Ekk KEk kkk kkk k KC Ck kk kk ke ke ke ke koe ke ke k ckckck ck KKK Section Styles CK C CK CK C 0k Ck Ck 0k Ck Ck Ck 0k CK kk 0k Ck ck KK KKK KEK Ck kk Ck CK ck ck ck kk Ck KKK Ck kk 0k kk ck ck kk ko kk ko ko Sk Sk kx kx kv ko ko ko HK KK ke kx x x Style cache for points in the photo layer type array var styleCache Style function for points in the photo layer param ol Feature featur param real resolution returns ol sty
30. undefined switch delta case 2 fill egba 215 25 29 0 1 stroke d7191lc lineDash 3 6 break case 1 fill sgba 255 178 97 Q0 L stroke ffdae61 break case 1 fill rgba l 66 217 106 0 1 stroke a6d96a break case 2 fill e ba 26 150 65 0s 1 stroke 1a9641 lineDash 3 6 80 Juan Luis Rodas Rivera Technical Report break Create new style style new ol style Style fill new ol style Fill color fil stroke new ol style Stroke color stroke width 1 lineDash lineDash zIndex delta 2 1 Add it to style cache clusterStyleCache delta style Return the style return style H Style cache for polygons in the quadrat count layer Qtype array var qcStyleCache Style function for polygons in the quadrat count layer param ol Feature feature param real resolution returns ol style Style a A var qcStyleFunction function feature resolution Set text parameters if mode is explore var count 0 var text var hasText 0 if mode explore count feature get count if resolution lt 3900 text count toString hasText 1 Retrieve style from style cache var style qcStyleCache count _ hasText If style does not exist create it if style Create new style style
31. 1 3 Table data grab The table data grab stores information on each photo download process for a particular tag It has the structure shown on Table 3 Table 3 Structure of table data_grab Attribute Data type Allow nulls Description id serial No Unique identifier tag id integer No Identifier of the tag for which photos are downloaded total integer No Total number of photos for this download as reported by Flickr started timestamp No Date and time the download process 15 Juan Luis Rodas Rivera Technical Report started ended timestamp Yes Date and time the download process ended latest smallint No Whether this is the latest download for this tag reduced smallint No Whether photos for this download have been reduced The id attribute is the primary key of the table and is auto incremental The tag_id attribute is a foreign key to the table tag and is configured to perform cascaded deletes Check constraints are included for the following attributes The total attribute to only allow positive values e The started attribute to only allow values greater or equal than January 1 2000 e The ended attribute to only allow values greater than the started attribute e The latest and reduced attributes to only allow either 0 or 1 Boolean 6 1 4 Table photo tag The table photo_tag stores information on which tags have been applied for each photo It has the structure shown on Table 4 Table 4 Structure of table
32. 19 To create the layers that serve objects from the database perform the following steps for photo reduced and study area 36 Juan Luis Rodas Rivera Technical Report A UF o9 m On the menu on the left select Layers and then Add a new resource In the Add layer from dropdown select the data store created earlier Select Publish on one of the three objects mentioned above repeat for the rest On Declared SRS select EPSG 3857 Compute both bounding boxes Click Save Logged in as admin Bj Logout GeoServer Layers About amp Status Manage the layers being published by GeoServer F Server Status Add a new resource GeoServer Logs Q Remove selected resources Contact Information About GeoServer 2 gt gt Results 1 to 25 out of 30 items 4 Search Data EPSG 4326 MB Layer Preview D B nurc arcGridSample Arc Sample v El Workspaces E nurc img sample2 Pk50095 PN EPSG 32633 j Stores E Layers oO B nurc mosaic mosaic v EPSG 4326 iii Layer Groups E nurc worldImageSample Img Sample v EPSG 4326 9 Styles oO NM sde flickr cluster neighbors v EPSG 3857 Series e sde fickr photo EPSG 3857 amp wcs B wes O e sde flickr photo_reduced v EPSG 3857 lg wms I sde flickr quadrat_count Id EPSG 3857 Settings oO M sde flickr study area v EPSG 3857 a Global ml sde flickr study_area_quadrat v EPSG 3857 Figure 19 Example of the list of layers in GeoServer To create the laye
33. 3 input type text name timeframe from id sa timeframe from class form control value from maxlength 10 required required gt lt div gt echo lt label for sa_time_unit class col sm 1 control label Time unit lt label gt echo div class col sm 2 input type text name time unit id 2 sa time unit class form control maxlength 50 value time_unit required required gt lt div gt echo lt label for sa_time_units class col sm 1 control label gt No time units lt label gt echo lt div class col sm 2 input type number name time units id sa_time_units class form control min 1 max 999999999 step 1 value time units required required f gt s Giv gt o lt dive echo lt input id sa_geom type hidden name geom fons echo tag id gt 0 lt input type hidden name tag value tag id Prints a hidden input with seq 0 since there is no navigation echo lt input type hidden id seq value 0 Prints the quadrat count analysis dialogue a function printQuadratCounts gt Container for quadrat count analysis lt div class modal fade id 2 quadrat count tabindex 1 role dialog aria labelledby modalLabel aria hidden true gt lt div class modal dialog modal lg gt lt div class modal content gt lt div class modal header button type button class close data dismiss
34. 3857 38 Juan Luis Rodas Rivera Technical Report There should be seven layers on the layer list in GeoServer after following these steps An example of a view layer correctly configured is shown on Figure 20 Logged in as admin GeoServer E About amp Status J Server Status GeoServer Logs a Contact Information About GeoServer Data Xj Layer Preview E Workspaces 3 Stores Wi Layers Layer Groups 49 styles Services dis wcs f wFs amp wms Settings 8 Global EL E Coverage Access Edit SQL view Update the definition of the SQL view and its metadata View Name quadrat count SQL statement SELECT FROM quadrat count id seq SQL view parameters Guess parameters from SQL Add new parameter Remove selected Tile Caching HB Tie Layers e Caching Defaults Il Gridsets Disk Quota Security Escape special SQL characters df Settings Attributes W Authentication Refresh J Guess geometry type and srid dB ser Groups Roles ee OMNE NN Data id Integer 7 B Services count Long Desens geom Polygon v 3857 m Tools Figure 20 Example of how to set up a SQL view layer 10 1 4 Apache and PHP configuration For a detailed guide on how to set up Apache with PHP and Phlickr see Kunkle and Morton 2006 A working installation of Apache HTTP Server configured with PHP is required for the application to run If the user needs
35. Ck kk ok Sk kk kk Sk Ck ko ko k ko Mk ko Mk ko ko ko ko ko ko ko ko KKK ke kx x x Tile base layer for MapQuest OSM Qtype ol layer Tile lt 7 var baseLayer new ol layer Tile source new ol source MapQuest layer osm 82 Juan Luis Rodas Rivera GeoJSON source for the study area layer type ol source GeoJSON var saSource Vector layer for the study area type ol layer Vector f var saLayer GeoJSON source for the quadrat count layer type ol source GeoJSON jf var qcSource Vector layer for the quadrat counts type ol layer Vector n var qcLayer GeoJSON source for the cluster layer type ol source GeoJSON qu var clusterSource Vector layer for the clusters type ol layer Vector f var clusterLayer GeoJSON source for the photo layer type ol source GeoJSON var photoSource Vector layer for the photos type ol layer Vector f var photoLayer Feature overlay for study area drawing type ol FeatureOverlay M var featureOverlay Innitial view of the map type ol View var view new ol View Technical Report 83 Juan Luis Rodas Rivera Technical Report center 0 0 zoom 2 Select interaction to modify study areas type ol interaction Select var select Modify interaction to modify stu
36. DELETE CASCADE CONSTRAINT fk grabbed photo photo FOREIGN KEY photo id REFERENCES photo id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE Table filtered photo CREATE TABLE filtered photo id integer NOT NULL CONSTRAINT pk filtered photo PRIMARY KEY id CONSTRAINT fk filtered photo photo FOREIGN KEY id REFERENCES photo id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE Table study area CREATE TABLE study area id serial NOT NULL tag id integer NOT NULL description character varying 50 NOT NULL DEFAULT No description quadrat_size real NOT NULL DEFAULT 0 CHECK quadrat_size gt 0 min_accuracy smallint NOT NULL DEFAULT 16 CHECK min_accuracy BETWEEN 1 AND 16 eps real NOT NULL CHECK eps gt 0 min_pts integer NOT NULL CHECK min_pts gt 1 time unit interval NOT NULL CHECK time unit gt 1 day interval time units integer NOT NULL CHECK time units 0 timeframe from timestamp NOT NULL CHECK timeframe from gt 2000 01 01 timestamp timeframe to timestamp NOT NULL CHECK timeframe from timeframe to calculated smallint NOT NULL DEFAULT 0 CHECK calculated BETWEEN 0 AND 1 updated timestamp NOT NULL DEFAULT CURRENT TIMESTAMP CHECK updated gt 2000 01 01 00 00 00 timestamp geom geometry POLYGON 3857 NOT NULL CONSTRAINT pk_study_area PRIMARY KEY id CONSTRAINT fk_study_area_tag FOREIGN KEY tag_id REFERENCES tag id MATCH SIM
37. PHP code for the main web pages Code for manual php and license php are not listed here for simplicity index php lt DOCTYPE html lt This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt gt lt Author Juan Luis Rodas Rivera Copyright c 2014 Juan Luis Rodas Rivera and The University of Edinburgh html Llang en gt head meta charset utf 8 meta http equiv X UA Compatible content IE edge meta name viewport content width device width initial scale 1 title Control Panel Tempo spatial explorer of Flickr tags lt title gt lt link rel icon type image png href img map png gt lt link rel stylesheet href css bootstrap css type text css gt lt link rel stylesheet href css bootstrap theme css type text css gt lt link rel stylesheet href c
38. Public API Phlickr is used in the project to query Flickr and retrieve information on the photos and tags 2 4 JavaScript JavaScript is a scripting language used mostly in web pages All modern web browsers include an engine capable of parsing and processing code written in JavaScript It can access and manipulate the DOM giving client side interaction and processing capabilities to a web page Mozilla Developer Network 2014a Three JavaScript libraries are used by the application e jQuery is used to provide easy DOM manipulation and traversing e Bootstrap is used to provide theming and interactivity e OpenLayers 3 is used to provide web mapping capabilities to the application 1 jOuery http www jquery com Bootstrap http www getbootstrap com 3 OpenLayers 3 http www ol3js org Juan Luis Rodas Rivera Technical Report 3 Architecture The tool uses the typical client server architecture for a web application Requests to the tool are made via a web browser to the application s main webpage The browser connects to the web server and sends requests for web pages to be loaded These web pages contain PHP code which is used to retrieve information and data from the database based on the request made by the user The PHP parser reads these PHP files and creates the necessary HTML code which is sent back to the browser The requests for geographical information on the client side are made by OpenLayers and are hand
39. Sconn pg connect CONN STRING Mark all previous data grabs for this tag as not being the latest pg update conn data grab array latest gt 0 array tag id gt Sthis gt tag gt getId latest gt 1 Store the new data grab on the database Ssql INSERT INTO data grab tag id total started VALUES Sthis tag getId Sthis 5total S this getStarted pg_query Sconn sql Retrieve the unique identifier Sthis gt id pg_fetch_result pg_query Sconn SELECT currval data grab id seq 0 0 pg close conn 117 Juan Luis Rodas Rivera Technical Report Returns the date to be used as minimum upload date for the data download return string private function getMinUploadDate Define a default date to return Sreturn 2000 01 01 00 00 00 Retrieve the last time this tag was updated Sconn pg connect CONN STRING Ssql SELECT MAX started FROM data grab WHERE tag id Sthis gt tag gt getId result pg query conn sql If the tag has been updated before return that date if pg_field_is_null Sresult 0 0 return pg_fetch_result result 0 0 pg_close return Sreturn Recalculates parameters when total of pictures excedes 4000 param string 1t Latest timestamp ar private function recalculateParams Sit Set new parameters if more than 4000 photos 16 pages x 250
40. add mode function add Send identifier of the tag goToViewer sa_tag val add 77 Juan Luis Rodas Rivera Technical Report Go to viewer on copy mode ud function copy Send identifier of the tag S sa_id2 val sa_tag val Send identifier of the study area goToViewer Sa_copy_id val copy Shows the delete confirmation dialogue param string type Either study area or tag param integer id Unique identifier of the object to delete param string description The name or description of the object delete o ox ct O y function del type id description Sets the values on the delete confirmation dialogue S del_type text type S del_id text id S del_desc text description Shows the delete confirmation dialogue S delete_confirmation modal Deletes an object from the database ur function del db Checks which object to delete if S fdel type text Tag Removes the tag from the list S tag_ S ftdel id text remove Removes all related study areas from the list study area tag del_id text remove else Removes the study area from the list S study_area_ del_id text remove Initiates AJAX request to delete the selected object from the database post action ww_delete php type del_type
41. area needs to delete cluster calculated return boolean private function needsClusterDeletion 139 Juan Luis Rodas Rivera Technical Report return Sthis gt upd_eps or Sthis gt upd_from or this gt upd_geom or this upd min accuracy o or Sthis upd time units Class constructor param param param tag Stag Th string des area param real Squadr area param the study area integer Smi r Sthis upd min pts or S this gt upd_time_unit integer id The unique identifier of the study area e tag asociated to the study area cription The textual description of the study at size The quadrat size used in the study n accuracy The minimal accuracy for photos in param real Seps T algorithm param integer Smi a cluster on the DBSCAN a param param study area param integer Sti string fro string S time u he search radius for neighbours on the DBSCAN n pts The minumum number of points to create lgorithm nit The time unit used on the study area units The number of time units in the me m The staring date of the timeframe param string geom The geometry of the study area function _ construct Sid Stag null Sdescription null Squadrat_size null min accuracy null Seps null Smin_pts null time unit null S time_units null S from null geom null If the identifier was specified t
42. b id ORDER BY a description b name while row pg fetch row S result4 echo lt option value row 0 row 1 row 2 lt option gt PHP EOL t t pg close conn select lt div gt lt faiv gt lt div class form group gt div class col sm offset 2 col sm 5 button type button class btn btn default onclick copy gt lt span class glyphicon glyphicon export span Copy lt button gt div div lt form gt lt div gt lt div gt lt div gt lt Footer gt lt php include include footer php lt body gt lt html gt 65 Juan Luis Rodas Rivera Technical Report viewer php lt php if array_key_exists mode POST header Location index php die gt lt DOCTYPE html lee This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt gt
43. getGeomAsWKT string getld int getNeighbours Seps float Stag tag min accuracy int Sgeom string Sfrom string Sto string photo getNum string getSecret string getServer int getUser string store Stag tag dg data grab Figure 9 Class diagram for photo class Sid int name string Figure 10 Class diagram for tag class 27 Juan Luis Rodas Rivera Technical Report Sapi Phlickr_Api Sended DateTime Sid int n photos int Spage int Spages int Sparms Mixed Sstarted DateTime Stag tag Stotal int done getMinUploadDate string getNPhotos int getStarted string getTag tag getTotal int grab recalculateParams Slt string Figure 11 Class diagram for data_grab class Sdensity_reachable photo Sid int Spoints photo add Spoint photo Sdensity_reachable bool getNumPoints int getPoints photo store Sid int Sseq int Seps float Figure 12 Class diagram for cluster class dbscan_algorithm Sclusters cluster Seps float Sfrom string Sgeom string Smin_accuracy int Smin_pts int Spoints photo Stag tag Sto string Svisited int expand cluster Scluster cluster Spoint photo Sneighbours photo cluster find_clusters getClusters cluster getEps float getMinPoints int
44. getNumClusters int merge Sseeds photo neighbours photo photo store Sid int Sseq int Figure 13 Class diagram for dbscan algorithm class 28 Juan Luis Rodas Rivera Technical Report Scalculated int Sdescription string Seps float Sfrom string Sgeom string id int min accuracy int min pts int Squadrat_size float Stag tag Stime_unit string Stime_units int Sto string Supd description bool Supd_eps bool Supd_from bool S upd geom bool upd min accuracy bool S upd min pts bool upd quadrat size bool Supd time unit bool Supd time units bool Supdated string calculate int copy Snew_tag tag study area getCalculated int getDescription string getEps float getFrom Sindex int DateTime getGeom string getGeomAsWKT string getld int getInterval Datelnterval getMinAccuracy int getMinPts int getNumPhotos Sindex int int getQuadratGeom string getQuadratSize float getTag tag getTimeUnit string getTimeUnits int getTo Sindex int DateTime getUpdated string needsClusterDeletion bool needsUpdate bool setDescription Sdescription string setEps Seps float setMinAccuracy min accuracy int setMinPts Smin_pts int setQuadratSize Squadrat size float setTimeUnit Stime unit string
45. gt lt var gt k lt var gt lt var gt amp micro lt var gt lt sup gt 2 lt sup gt lt th gt lt tr gt lt thead gt lt tbody gt lt php Mean quadrat count mu n S total Ssum 0 Get values for the quadrat count distribution Sresult2 pg query conn SELECT count as photos COUNT AS quadrat FROM quadrat count sa seq GROUP BY photos ORDER BY photos while Srow pg fetch row result2 Number of events minus mean k minus mu row 0 mu Number of events minus mean squared S k minus mu2 pow k minus mu 2 Number of events minus mean squared times number of quadrats x times k minus mu2 row 1 Sk minus mu2 sum x times k minus mu2 Round values for displaying tdl round row 0 4 td2 round row 1 4 td3 round Srow 1 total 4 td4 round k minus mu 4 td5 round k minus mu2 4 Std6 round x times k minus mu2 4 echo tr td td td class text right gt td1 lt td gt lt td class text right td2 td td class text right gt td3 lt td gt lt td class text right gt td4 lt td gt lt td class text right gt td5 lt td gt lt td class text right gt S td6 lt td gt lt tr gt pg close S conn Round values for displaying Std7 round sum 4 echo lt tr gt lt td class text right gt lt strong gt TOTAL lt strong gt lt td gt lt td class text right gt lt strong gt n lt strong g
46. installed on a production server or on a location where it will be deployed permanently It is not recommended to perform the full installation on a machine if the tool is going to be used just for testing or browsing since it will be lengthy and involve the installation of various programs services and the editing of configuration files If the tool is to be used for testing or browsing then the virtual machine installation described on the next section is more appropriate 10 1 1 Requirements The application can be installed on either a Windows or a Linux host Installation on Mac hosts should be similar but this has not been tested The following is a list of the software used to develop and test the application These are considered the minimum requirements to run the tool Newer versions of these programs should be used if available e Apache HTTP Server 2 4 9 with PHP 5 5 12 e GeoServer 2 52 on Apache Tomcat 8 0 9 e PostgreSQL 9 3 4 with PostGIS 2 1 Step by step instructions on how to install each of these programs are out of the scope of this technical report Guides on how to install these programs are readily available online This document will only present the specific configuration steps that need to be taken for the application to run on a hypothetic newly installed system running the above mentioned programs 5 VirtualBox http www virtualbox org 34 Juan Luis Rodas Rivera Technical Report 10 1 2 Postgre
47. key of the table and is auto incremental The num attribute is the unique identifier used by Flickr for the photo and constitutes an alternate key A unique constraint is declared for this attribute so two photos with the same num cannot be inserted The geom attribute is spatially indexed to improve query performance Check constraints are included for the following attributes e The num and server attributes to only allow values greater than zero e The date_added and date_taken attributes to only allow values greater or equal than January 1 2000 14 Juan Luis Rodas Rivera Technical Report e The accuracy attribute to only allow values between 1 and 16 e The lat attribute to only allow values between 90 and 90 e The lon attribute to only allow values between 180 and 180 e The farm attribute to only allow values between 1 and 9 6 1 2 Table tag The table tag stores the tags defined by the user for tempo spatial exploration It has the structure shown on Table 2 Table 2 Structure of table tag Attribute Data type Allow nulls Description id serial No Unique identifier name character varying No Tag description 50 The id attribute is the primary key of the table and is auto incremental The name attribute constitutes an alternate key since two tags with identical names on the application cannot exist A unique constraint is declared for this attribute so two tags with the same name cannot be inserted 6
48. of function cluster neighbours ess 24 Table 16 Structure of the output of function study area as hex quadrat s 25 Table 17 Structure of the output of function cluster neighbours esses 26 Table 18 User logins and passwords for services on the virtual machine 44 iii Juan Luis Rodas Rivera Technical Report 1 Introduction This document provides the technical documentation that describes how the tool was developed and how it works internally It is structured progressively starting with a descriptive overview of the technologies used to develop the application and how these technologies were translated into the architecture used by the application The document then describes the requirements used as basis for the development of the tool and how the progressively become part of the database design and physical implementation and part of the developed object oriented software solution The document also describes how the web application is structured and what layers are published as web services for consumption by the tool The last part of the document provides detailed instructions on how to install the application whether for deployment on a production environment with full documentation on detailed configuration or for testing purposes on a ready to run virtual machine that can be deployed anywhere Juan Luis Rodas Rivera Technical Report
49. photo tag Attribute Data type Allow nulls Description photo id integer No Identifier of the tagged photo tag id integer No Identifier of the tag used on the photo The photo id and tag id attributes are the compound primary key of the table The photo id attribute is a foreign key to the table photo and the tag id attribute is a foreign key to the table tag Both are configured to perform cascaded deletes 16 Juan Luis Rodas Rivera Technical Report 6 1 5 Table grabbed photo The table grabbed photo stores information on which download process downloaded which photo It has the structure shown on Table 5 Table 5 Structure of table grabbed photo Attribute Data type Allow nulls Description data grab id integer No Identifier of the photo download process photo id integer No Identifier of the downloaded photo The data grab id and photo id attributes are the compound primary key of the table The data grab id attribute is a foreign key to the table data grab and the photo id attribute is a foreign key to the table photo Both are configured to perform cascaded deletes 6 1 6 Table filtered photo The table filtered photo stores the identifiers of the photos which have passed the pre processing process It has the structure shown on Table 6 Table 6 Structure of table filtered photo Attribute Data type Allow nulls Description id integer No Identifier of the photo The id attribute is the primary key of the table
50. tag The study area must have an extent both in space and time REQ 06 For each study area the tool must allow the user to calculate a set of clusters for every consecutive time unit REQ 07 The tool must show the clusters on a map showing for each cluster on a particular time unit all clusters that overlap with it in the neighbouring time units REQ 08 The tool must allow the user to navigate through different time units REQ 09 For each study area the user must be able to see the distribution of clusters on the timeframe REQ 10 The user must be able to validate the results of each study area with quadrat count analysis The analysis performed by the tool assumes that every photo on the reduced dataset represents one event Juan Luis Rodas Rivera Technical Report 5 Database design 5 1 Entities Taking into consideration the requirements described on the previous section five entities were defined for the application 5 1 1 Photo entity This entity represents a photo that has been downloaded from Flickr Flickr stores a great number of attributes as metadata for each photo that is uploaded to their servers From these attributes the tool will query and store the photo id and the id of the owner additional data on the owner such as names or usernames will not be downloaded since the tool makes no use or attempt to identify a single user for any particular kind of analysis Temporal data on the photos will be do
51. var string 5 private secret Returns the unique identifier of the photo return integer Tar public function getId return Sthis ig Returns the unique idenfifier of the photo used by Flickr return string x public function getNum return this num Returns the date the photo was added return string di public function getDateAdded return S this gt dateAdded 127 Juan Luis Rodas Rivera Technical Report Returns the date the photo was taken return string public function getDateTaken return S this dateTaken Returns the declared accuracy of the photo return integer yf public function getAccuracy return Sthis gt accuracy Returns the identifier of the user that uploaded the photo return string A public function getUser return this user Returns the server farm where the photo is hosted return integer public function getFarm return Sthis gt farm Returns the server where the photo is hosted return integer E public function getServer return this server Returns the secret of the photo return string sy public function getSecret return this secret Returns the geometry of the photo as expected to be inserted in the database return string ar public function getGeom return ST Transform ST GeomFromT
52. 2 Overview of technologies used The development of the tool required the selection of a set of components that could work together and perform well For this task an array of open source technologies was selected based on the author s familiarity with each technology From a design point of view the technologies used can be divided into server side and client side Green and Bossomaier 2002 Server side technologies include the database management system which is required to store the information extracted from Flickr a WMS WES compliant web server which can read geographic information from the database and serve it over a network on the necessary formats and an HTTP web server with a scripting language to retrieve and store information from the database and serve the HTML web pages that make the frontend of the web application Client side technologies include various JavaScript APIs and libraries and CSS styling to give enhanced interactivity to the end user of the web application 2 1 PostgreSQL with PostGIS PostgreSQL is an open source object relational database system Originally named Postgres it was created by Michael Stonebreaker at the University of California at Berkeley in 1986 in 1995 an extended subset of the SOL query language was added to Postgres and in 1996 the project was taken by the open source community PostgreSQL Global Development Group 2014b PostgreSQL was chosen because of its open source nature and
53. 2 class panel title gt lt span class glyphicon glyphicon map marker gt lt span gt Add study area lt h2 gt lt div gt lt div class panel body gt lt form role form class form horizontal lt div class form group gt label for sa_tag class col sm 2 control label For tag lt label gt lt div class col sm 5 gt lt select name tag id sa_tag class form control required required gt lt php 64 Juan Luis Rodas Rivera Technical Report Fill select with the tag names Sresult3 pg query conn SELECT FROM tag ORDER BY name while row pg fetch row S result3 echo lt option value Srow 0 gt row 1 lt option gt PHP EOL t t select f dise div div class form group div class col sm offset 2 col sm 5 button type button class btn btn default onclick add gt lt span class glyphicon glyphicon plus span Add lt button gt div div div class form group span class col sm 2 label label info gt Or copy geometry from lt span gt div div class form group label for sa copy id class col sm 2 control label Study area lt label gt lt div class col sm 5 lt select name id id 2 sa copy id class form control required required gt lt php Fill select with the study areas Sresult4 pg query conn SELECT a id a description b name FROM study area a INNER JOIN tag b ON a tag id
54. A tool for exploring the tempo spatial distribution of Flickr tags Part II Technical Report Juan Luis Rodas Rivera Technical Report Table of Contents l dufroduetlOaoeose ue ions pertes rd ota eesti eda ue eost oe esie el sit ve bein enel 1 2 Overview of technologies sed ou c pe inate vies dee E iie 2 XI PostereSQL with POStGIS cei te itat ittis dia ete tette dre devi cdd 2 PME CTI I iS ER 3 23 Apache with PHP Sonia cede ia IE RR E RN ER cine NL eis 3 2 EN iussis T 4 D PRTC IMB CEC S ui ete p tbe E RE due e ai RR dh nc a Re E ASRS 5 4 Requirements and assumptions anite rte tein tessera dece oeque 6 5 iDa bibase desiBtiads as eat ele a i e etd as qaad e ante tat tail ent 7 VE YUEN LOS e RE 7 5 2 Relationships ques es elio besito qur e ritiene a rdc ios 10 X Domas a s e a ado aie E E canted bites isda bin ka leaves E EE aae 11 6 Physical database cists tette aet biete id e les A S 13 sh TAIT 15 OMS Io Giacinto emanate 20 63 FUNCHONS cauti re m tr Ea ESA M vals de e edu es eR M PRU eave wheal tans 24 TE E VET ES 27 3o vGep5erver layers eieaa coa hi EREE EES Aei E roe lea la 30 9 WWebapplicat On SEPGLCBDTEOS ecole ido e e a A taba E E meals 31 10 Installation PETS 34 TOI UML Stall escrian ias inia ea EEE EE ERE AEE EEE EY 34 10 2 Vitt al machineinstalli oo e ro ut tb tto t a piri aS 42 References ucmop put pp a mpi dtt ditte t tet Rete 45 P
55. DBSCAN algorithm param string from The starting date of the timeframe param string time unit The time unit of the timeframe param integer time units The number of time units in the timeframe function printStudyAreaForm tag id 0 desc quad size 50000 min acc 16 Seps 500000 S min pts 5 S from 2010 01 01 time unit 1 month time units 12 echo Study area form PHP EOL lt div class panel panel default div class panel body Prints the opening tag of the form depending on the action taken by the user adding or creating a study area echo tag id 0 form action action ww study area php id add study area method POST class form horizontal role form lt form class form horizontal role form Prints the inputs used to define the study area echo lt div class form group label for sa_description class col sm 3 control label gt Description lt label gt echo lt div class col sm 3 input type text name description id sa_description class form control maxlength 50 value desc required required placeholder Enter a description for the study area gt lt div gt echo lt label for sa_quadrat_size class col sm 1 control label Quadrat size lt label gt echo lt div class col sm 2 input type number name quadrat size id sa_quadrat_size class form control min 1 max 999999999 ste
56. ICKR API SECRET Test connectivity with Flickr try rsp Sapi gt ExecuteMethod flickr test echo array foo gt bar 60 Juan Luis Rodas Rivera Technical Report echo lt div class alert alert success role alert echo The Flickr API REST endpoint is lt strong gt online lt strong gt img src img accept button png alt Online riu catch Exception Sex echo lt div class alert alert danger role alert echo The Flickr API REST endpoint is lt strong gt offline lt strong gt cannot download new photos img src img exclamation png alt Offline finally echo button type button class close data dismiss alert gt lt span aria hidden true amp times span span class sr only gt Close lt span gt lt button gt echo lt div gt gt lt Page header gt lt div class page header gt lt h2 gt lt span class glyphicon glyphicon dashboard gt lt span gt Control panel lt h2 gt lt div gt List of tags section div id tags class panel panel default div class panel panel heading lt h2 class panel title gt lt span class glyphicon glyphicon tags gt lt span gt amp nbsp amp nbsp Current tags lt h2 gt lt div gt lt div class panel body lt p gt This is the list of tags currently downloaded by the tool lt p gt lt div gt lt table class table table striped gt lt thead gt SEIT
57. License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt i Styling for viewer php Author Juan Luis Rodas Rivera x Copyright c 2014 Juan Luis Rodas Rivera and The University of Edinburgh E body padding top 25px navigator border collapse collapse width 100 navigator tr bars height 41px navigator td minus2 background color d7191c color ghostwhite navigator td minus1 background color fdae61 navigator td selected background color ffffbf font weight bold border left lpx solid black border right lpx solid black font size small navigator td overlaps background color steelblue color ghostwhite font weight bold 96 Juan Luis Rodas Rivera Technical Report navigator td plusl background color a6d96a navigator td plus2 background color 1a9641 color ghostwhite navigator td year border left lpx solid gainsboro border right lpx solid gainsboro navigator td year first border left none na
58. PLE ON UPDATE RESTRICT ON DELETE CASCADE 50 Juan Luis Rodas Rivera Technical Report Table cluster CREATE TABLE cluster id serial NOT NULL study area id integer NOT NULL seq integer NOT NULL CHECK seq gt 0 geom geometry POLYGON 3857 NOT NULL CONSTRAINT pk cluster PRIMARY KEY id CONSTRAINT fk cluster study area FOREIGN KEY study area id REFERENCES study area id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE Table cluster photo CREATE TABLE cluster photo cluster id integer NOT NULL photo id integer NOT NULL CONSTRAINT pk cluster photo PRIMARY KEY cluster id photo id CONSTRAINT fk cluster photo cluster FOREIGN KEY cluster id REFERENCES cluster id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE CONSTRAINT fk cluster photo filtered photo FOREIGN KEY photo id REFERENCES filtered photo id MATCH SIMPL ON UPDATE RESTRICT ON DELETE CASCADE Es INDEXES Geographic index for photos CREATE INDEX gx photo ON photo USING GIST geom Geographic index for study areas CREATE INDEX gx study area ON study area USING gist geom Geographic index for clusters CREATE INDEX gx cluster ON cluster USING GIST geom VIEWS View that summarises area and count of the clusters in the database CREATE OR REPLACE VIEW cluster summary AS SELECT study area id seq SUM ST Area geom AS area COUNT seq AS count FROM cluster
59. Rivera and the University of Edinburgh author Juan Luis Rodas Rivera f Connection string to connect to the database define CONN STRING host localhost dbname flickr user postgres password flickr Flickr API key define FLICKR API KEY 875c7452aaea518daab4907211dc1f89 Flickr API secret xd define FLICKR API SECRET e293d50b4c392c40 Coordinate system used for the geometries on the database Ay define EPSG 3857 Address of host where geoserver is running Xy define GEOSERVER http localhost 146
60. SQL configuration PostGIS is an extension to PostgreSQL that needs to be enabled in the database that will host the data for the tool PostGIS Development Group 2014a To enable PostGIS for a database the following command can be run from PostgreSQL s prompt CREATE EXTENSION postgis Or if the user has access to pgAdmin III then right clicking on the extensions list of any database and selecting New Extension will bring a graphical interface from which PostGIS can be selected and installed It is recommended to create a new database for the use of the tool as to not interfere with other existing applications After enabling PostGIS in the database that will be used by the application it is necessary to run the database creation script This script is included on the accompanying DVD on the folder sql and is also listed on Appendix A Running this script will create all the necessary tables views and functions needed by the application to work Please note that the script will create the database objects in the public schema 10 1 3 GeoServer configuration GeoServer can either be installed standalone or on top of Apache Tomcat Both kinds of installations will work fine for the application Once GeoServer has been installed head to its main web page and login the default username is admin and the default password is GeoServer For this example GeoServer will be located in http localhost 8080 GeoServer To
61. Sextra_class colspan k gt Scurrent_year lt td gt Reset colspan Sk 0 Assign new current year Scurrent_year new year Increase colspan Sk Print all rows of the time slider echo Srowl lt tr gt PHP EOL Srow2 lt tr gt PHP EOL row3 lt tr gt PHP FOL echo lt tbody gt lt table gt 71 Juan Luis Rodas Rivera Technical Report Print the time slider controls echo lt div class panel footer div class row Smax S obj getTimeUnits 1 echo div class col sm 4 text left small input type range id seq min 0 max Smax step 1 value 0 class hidden gt echo lt span id from gt Sobj gt getFrom gt format Y wd Heiss lt span gt echo span class label label info gt to lt span gt echo lt span id to gt Sobj gt getTo 0 gt format Y m d H i s lt span gt lt small gt lt div gt PHP EOL echo lt div class col sm 4 text center div class btn group btn group xs button type button class btn btn default onclick first gt lt span class glyphicon glyphicon fast backward gt lt span gt lt button gt PHP EOL echo lt button type button class btn btn default onclick rewind gt lt span class glyphicon glyphicon backward gt lt span gt lt button gt PHP_EOL echo lt button type button class btn btn default onclick prev gt lt span cl
62. TNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt ul require once include study area php Script in charge of performing data insertion and update for study areas copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera a If the id of the study are was not sent on POST then create a new study area if empty htmlspecialchars S_POST id require_once include tag php Get the tag Stag new tag htmlspecialchars POST tag Create the study area object with the parameters sent by the user sa new study area 0 Stag htmlspecialchars POST description htmlspecialchars POST quadrat size htmlspecialchars POST min accuracy htmlspecialchars POST eps htmlspecialchars POST min pts htmlspecialchars POST time unit htmlspecialchars POST time units htmlspecialchars POST timeframe from htmlspecialchars POST geom Store the new study area in the database Ssa gt store Redirect back to the main page header Location index php die If the id is specified then load the study area from the database eise sa new study area htmlspecialchars POST id Set the new pa
63. The id attribute is a foreign key to the table photo and is configured to perform cascaded deletes 6 1 7 Table study area The table study area stores the study areas defined by the user and the parameters to perform cluster analysis It has the structure shown on Table 7 17 Juan Luis Rodas Rivera Attribute id tag_id description quadrat_size min_accuracy eps min_pts time_unit time_units timeframe_from timeframe_to calculated updated geom Technical Report Table 7 Structure of table study_area Data type serial integer character varying 50 real smallint real integer interval integer timestamp timestamp smallint timestamp geometry POLYGON 3857 Allow nulls No No No No No Description Unique identifier Identifier of the tag for the study area A textual description of the study area Size of the quadrats to use in cluster validation Minimum accuracy of the photos Search radius for neighbours Minimum number of points to define a cluster Time unit of the timeframe Number of time units in the timeframe Lower boundary of the timeframe Upper boundary of the timeframe Whether clusters have been calculated for this study area Date and time of last update to the study area Spatial extent of the study area The id attribute is the primary key of the table and is auto incremental The tag_id attribute is a foreign key to the table tag and
64. a and is configured to perform cascaded deletes The geom attribute is spatially indexed to improve query performance 19 Technical Report Juan Luis Rodas Rivera Technical Report A check constraint is included for the seq attribute to only allow positive values 6 1 9 Table cluster photo The table cluster photo stores information on which photos belong to a cluster It has the structure shown on Table 9 Table 9 Structure of table cluster photo Attribute Data type Allow nulls Description cluster id integer No Identifier of the cluster photo id integer No Identifier of the photo The cluster id and photo id attributes are the compound primary key of the table The cluster id attribute is a foreign key to the table cluster and the photo id attribute is a foreign key to the table filtered photo Both are configured to perform cascaded deletes 6 2 Views Five views where defined in the database to allow easier querying by the application These views are mostly used to present summaries of the data to the user The script for the creation of the views is included in Appendix A 6 2 1 View cluster summary The view cluster summary summarises the area and the number of clusters for each time unit on each study area It has the structure shown on Table 10 Table 10 Structure of view cluster summary Attribute Data type Description study area id integer Study area identifier seq integer Sequential of time unit
65. add a new data store that connects to the recently created database for the application perform the following steps e On the menu on the left select Stores and then Add new store e Under Vector Data Sources select PostGIS e Select a workspace for the new data store and add a name and a description 35 Juan Luis Rodas Rivera Technical Report e On the database connection parameters specify the address where PostgreSQL is installed the port or leave the default the name of the database where the application objects were created and the username and password to connect e Select Expose primary keys and increase fetch size to 50000 e Click Save An example of this configuration can be seen on Figure 18 Basic Store Info Workspace sde Y Data Source Name flickr Description Flickr photos dataset Enabled Connection Parameters host localhost port 5432 database flickr schema user postgres passwd Namespace http geoserver sf net 7 Expose primary keys max connections 10 min connections 1 fetch size 50000 Figure 18 Configuration example for a GeoServer data store The application uses six layers served from GeoServer to display geographical information Two of these layers are configured to serve tables or views from the database the other four layers are views defined on GeoServer The list of layers is shown under the sde workspace in Figure
66. ap map Add modify interaction to edit the study area modify new ol interaction Modify features featureOverlay getFeatures map addInteraction modify Add draw interaction to add a study area draw new ol interaction Draw features featureOverlay getFeatures type Polygon map addInteraction draw When study area has been drawn draw on drawend function Remove draw interaction map removelInteraction draw Enable store button S btn_store attr disabled false 86 Juan Luis Rodas Rivera Technical Report If exploring bind layer visibility to layer list buttons if mode explore map getLayers forEach function layer i new ol dom Input layer i 0 bindTo checked layer visible OK KKK KK kk I A OK kk A Kk I KC SK CK kk kk kk I A I KK KK KAKKKKKKKK Section Interactivity CK C CK KEK KEK KKK KKK KK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK KKK Sk Sk ko Sk ke kx Kk ko kv ko ko kK KK kx amp x Switch layer visibility on layer list click label btn on ceclick function Get selected layer var label S this var checkbox label find input Switch visibility checkbox prop checked checkbox is checked Fire visibility change var ev document createEvent Event ev initEvent change true false checkbox 0 dispatchEvent ev
67. aracter varying 50 NOT NULL CONSTRAINT pk tag PRIMARY KEY id CONSTRAINT uk tag UNIQUE name Table data grab CREATE TABLE data_grab id serial NOT NULL tag_id integer NOT NULL total integer NOT NULL CHECK total gt 0 started timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP CHECK started gt 2000 01 01 00 00 00 timestamp ended timestamp CHECK started lt ended latest smallint NOT NULL DEFAULT CHECK latest BETWEEN 0 AND 1 reduced smallint NOT NULL DEFAULT 0 CHECK reduced BETWEEN 0 AND 1 CONSTRAINT pk data grab PRIMARY KEY id CONSTRAINT fk data grab tag FOREIGN KEY tag id REFERENCES tag id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE Table photo tag CREATE TABLE photo tag photo id integer NOT NULL tag id integer NOT NULL CONSTRAINT pk photo tag PRIMARY KEY photo id tag id 49 Juan Luis Rodas Rivera Technical Report CONSTRAINT fk_photo_tag_photo FOREIGN KEY photo_id REFERENCES photo id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE CONSTRAINT fk_photo_tag_tag FOREIGN KEY tag_id REFERENCES tag id MATCH SIMPLE ON UPDATE RESTRICT ON DELETE CASCADE Table grabbed photo CREATE TABLE grabbed photo data grab id integer NOT NULL photo id integer NOT NULL CONSTRAINT pk grabbed photo PRIMARY KEY data grab id photo id CONSTRAINT fk grabbed photo grab FOREIGN KEY data grab id REFERENCES data grab id MATCH SIMPLE ON UPDATE RESTRICT ON
68. are table php Slookup 1 gt 0 0000393 0 000982 1 642 2 706 3 841 5 024 5 112 62635 7 879 9 550 10 828 2 gt 0 0100 020506 3 219 4 009 5 991 7 315 7 924 9 210 10 597 12 4229 13 815 2 D0OTIT D 216 0 542 6 251 7 515 92 348 8 927 11 345 12 930 14 796 16 266 4 gt D 207 0 484 5 989 7 779 9 488 11 143 17 668 13 277 14 860 16 924 18 4267 5 gt D 412 0 831 7 289 9 236 11 070 12 833 13 299 15 085 15 750 18 907 20 515 Whole array ommited for simplicity view source file on disk 105 Juan Luis Rodas Rivera Technical Report 1000 gt 9890 9604 914 257 LUST 431 1057 724 1074 679 1089 5231 10932 977 11105 9609 1118 948 1133 579 13143 9171 div class panel panel heading lt h4 class panel title gt Frequency distribution of quadrat counts lt h4 gt lt div gt lt table class table table hover lt thead gt lt tr gt lt th gt lt th gt lt th class text right gt No photos lt var gt k lt var gt lt th gt lt th class text right gt No quadrats lt var gt x lt var gt lt th gt lt th class text right gt Proportion lt th gt lt th class text right gt lt var gt k lt var gt lt var gt amp micro lt var gt lt th gt lt th class text right gt lt var gt k lt var gt lt var gt amp micro lt var gt lt sup gt 2 lt sup gt lt th gt lt th class text right gt lt var gt x lt var
69. area double precision Area of clusters on this time unit count bigint Number of clusters on this time unit 20 Juan Luis Rodas Rivera 6 2 2 View photo reduced Technical Report The view photo reduced presents the metadata for the subset of photos that have been pre processed It has the structure shown on Table 11 Attribute id num date added date taken accuracy usr lat lon farm server secret geom tag id tag Table 11 Structure of view plioto reduced Data type integer bigint timestamp timestamp smallint character varying 15 real real smallint smallint character 10 geometry POINT 3857 integer character varying 50 6 2 3 View photo summary Description Identifier of the photo Photo identifier from Flickr Date photo was uploaded Date photo was taken Declared accuracy Owner of the photo Latitude where photo was taken Longitude where photo was taken Server farm hosting the photo Server hosting the photo Secret code of the photo Photo location Identifier of the tag used on the photo The tag used on the photo The view photo summary presents a summary of the photos that exist per tag It is used on the application s main page It has the structure shown on Table 12 21 Juan Luis Rodas Rivera Attribute id name count started reduced num_reduced Technical Report Table 12 Structure of view photo_summary Data type integer character varying
70. ary lists all photos that are located within all study areas It has the structure shown on Table 14 Table 14 Structure of view pliotos on study area Attribute Data type Description study area id integer Identifier of the study area tag id integer Identifier of the tag id integer Identifier of the photo num bigint Photo identifier from Flickr date added timestamp Date photo was uploaded date taken timestamp Date photo was taken accuracy smallint Declared accuracy usr character Owner of the photo varying 15 lat real Latitude where photo was taken lon real Longitude where photo was taken farm smallint Server farm hosting the photo server smallint Server hosting the photo secret character 10 Secret code of the photo geom geometry Photo location POINT 3857 23 Juan Luis Rodas Rivera Technical Report 6 3 Functions Five functions where defined in the database to perform spatial querying and analysis The scripts are written on PL PGSQL The script for the creation of the views is included in Appendix A 6 3 1 Function reduce photos This function populates the filtered photo table by selecting only one photo from the photo table for each user on a particular day and location thus removing all photos taken by the same user on the same day from the analysis Photos are selected based on their distance to the geographic mean of the group of points and the accuracy of the photos The function receives the identifier of the
71. ass glyphicon glyphicon step backward gt lt span gt lt button gt PHP_EOL echo lt button type button class btn btn default onclick next gt lt span class glyphicon glyphicon step forward gt lt span gt lt button gt PHP EOL echo button type button class btn btn default onclick forward gt lt span class glyphicon glyphicon forward gt lt span gt lt button gt PHP EOL echo button type button class btn btn default onclick last gt lt span class glyphicon glyphicon fast forward gt lt span gt lt button gt lt div gt lt div gt PHP EOL echo lt div class col sm 4 text right button type button class btn btn xs btn primary onclick quadrat counts Quadrat count analysis lt button gt lt div gt PHP EOL echo lt div gt lt div gt lt div gt PHP EOI break Map container lt div class panel panel default Map header lt div class panel heading text right div class row gt div class col sm 2 text left lt span class label label primary gt Viewer lt span gt lt div gt lt php if Smode explore gt Number of photos in time unit gt lt div class col md 4 text right span class label label info gt Photos span class badge gt lt php echo 0obj getNumPhotos gt lt span gt lt span gt div div class col md 2 t
72. block hidden data loading text Please wait onclick reduce_data Srow 0 gt lt span class glyphicon glyphicon screenshot span Reduce lt button gt lt span gt row 5 lt span gt Print row echo lt tr id tag_ Srow 0 gt lt td class text right gt Srow 0 lt td gt lt td gt S row 1 lt td gt lt td class text right gt row 2 lt td gt lt td class text right gt Srow 3 lt td gt lt td id pu_ Srow 0 gt lt button type button class btn btn sm btn default btn block data loading text Please wait onclick update_tag row 0 gt lt span class glyphicon glyphicon refresh gt lt span gt lt button gt lt td gt lt td gt reduced lt td gt lt td class text right id rd_ row 0 gt n_reduced lt td gt lt td gt lt div class btn group gt lt button class btn btn sm btn default disabled disabled gt lt span class glyphicon glyphicon download alt gt lt span gt lt button gt lt a class btn btn sm btn default href geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeName sde photo reduced amp outputFormat SHAPE ZIP amp cql filter tag id row 0 target _blank gt Reduced lt a gt lt a class btn btn sm btn default href geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeName sde photo amp outputFormat SHAPE IP amp cql_filter tag_id Srow 0 arget _b
73. by a specified step param integer a_step Positive or negative number of steps to move from the current time unit yf function step a_step Calculate new time unit var newlIndex parseInt seq val a step var max S seq attr max Check it falls within timeframe boundaries if newIndex lt 0 newIndex 0 else if newIndex gt seq attr max newIndex max Move time unit to new time unit move newIndex Move to the next time unit H function next step 1 Move to the previous time unit ef function prev step 1 Move three time units ahead x function forward step 3 Move three time units behind iri function rewind step 3 89 Juan Luis Rodas Rivera Technical Report Move to first time unit y function first move 0 Move to last time unit function last move S seq attr max Save edits made to the study area by the user function saveEdits Only save in edit mode if mode edit Get coordinates of drawn geometry var coords saSource getFeatures 0 getGeometry getCoordinates 0 Build WKT geom POLYGON coords forEach function val geom geom val 0 valji H geom geom substr 0 geom length 2ye Sw Set new minimum accuracy min_acc
74. can redistribute it and or modify it under the terms of the GNU General Public License as published by ct he Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details F F HF x You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt ul require once include vars php Script in charge of returning the results of quadrat analysis for a study area and sequential copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera ui Retrieve parameters study area and sequential sa htmlspecialchars POST sa Sseq htmlspecialchars POST seg Check if there are photos on this study area and time unit Sconn pg connect CONN STRING Sresultl pg query conn SELECT COUNT SUM count FROM quadrat count sa seq Stotal pg fetch result resultl1 0 0 n pg fetch result resultl 0 1 If there are points print analysis output in HTML format if n O Lookup table for chi square test Source http www medcalc org manual chi squ
75. covering the study area return string public function getQuadratGeom Sconn pg connect CONN STRING Retrieve beehive grid and merge all polygons result pg query conn SELECT ST AsText ST Union ST SnapToGrid geom 0 0001 AS geom FROM study area as hex quadrat this id SquadGeom ST GeomFromText pg fetch result result O0 0 mr n n EPSG my pg close conn return SquadGeom Returns the number of photos present on the study area param integer seq If specified returns the number of photos in this time unit return integer y public function getNumPhotos seq 1 Sconn pg connect CONN STRING if Sseq lt 0 Sresult pg query conn SELECT COUNT FROM photos on study area WHERE study area id Sthis gt id else Sfrom S this getFrom seq format Y m d H i s Sto Sthis getTo seq format Y m d H i s Sresult pg query conn SELECT COUNT FROM photos on study area WHERE study area id S this id AND date taken BETWEEN S from AND Sto pg_close Sconn if Sresult l Q 4 return pg fetch result result 0 0 else return Q Returns whether the study area needs updating return boolean private function needsUpdate return S this upd description or this upd quadrat size or Sthis gt needsClusterDeletion Returns whether the study
76. dix A SQL script to create the database Objects sse 49 Appendix B SQL script to remove the database objects sss 58 Appendix C PHP code for the main Web pages iie oto eter tete tens 59 Appendix D JavaScript code for the main Web pages sss 75 Appendix E CSS code for the mam web p pes ie cei secet tiet iet renta deis 95 Appendix F PHP code for the files in the action folder sese 99 Appendix G PHP code for the files in the include folder 112 48 Juan Luis Rodas Rivera Technical Report Appendix A SQL script to create the database objects TABLES Table photo CREATE TABLE photo id serial NOT NULL num bigint NOT NULL CHECK num gt 0 date added timestamp NOT NULL CHECK date added gt 2000 01 01 00 00 00 timestamp date taken timestamp NOT NULL CHECK date taken gt 2000 01 01 00 00 00 timestamp accuracy smallint NOT NULL CHECK accuracy BETWEEN 1 AND 16 usr character varying 15 NOT NULL lat real NOT NULL CHECK lat BETWEEN 90 AND 90 lon real NOT NULL CHECK lon BETWEEN 180 AND 180 farm smallint NOT NULL CHECK farm BETWEEN 1 AND 9 Server smallint NOT NULL CHECK server 0 secret character 10 NOT NULL geom geometry POINT 3857 NOT NULL CONSTRAINT pk photo PRIMARY KEY id CONSTRAINT uk photo UNIQUE num Table tag CREATE TABLE tag id serial NOT NULL name ch
77. down the virtual machine simply go to its prompt login if not logged in already and type juan s1366017 S sudo shutdown P now Type the system user password on Table 18 and the virtual machine will shut down 44 Juan Luis Rodas Rivera Technical Report References Butler H Daly M Doyle A Gillies S Schaub T and Schmidt C 2008 GeoJSON Specification online Available at lt http www geojson org geojson spec html gt Accessed 14 Jun 2014 ECMA International 2013 The JSON Data Interchange Format online Geneva Switzerland p 14 Available at lt http www ecma international org publications files ECMA ST ECMA 404 pdf gt Green D and Bossomaier T 2002 Online GIS and Spatial Metadata London UK Taylor amp Francis p 222 Kunkle R and Morton A 2006 Building Flickr Applications with PHP Berkeley CA USA Apress p 216 Martin C 2014 Flickr API going SSL Only on June 27th 2014 online Available at lt http code flickr net 2014 04 30 flickr api going ssl only on june 27th 2014 gt Accessed 27 Jun 2014 Mozilla Developer Network 2014a About JavaScript JavaScript MDN online Available at lt https developer mozilla org en US docs Web JavaScript About JavaScript Accessed 15 Jun 2014 Mozilla Developer Network 2014b Same origin policy Web security MDN online Available at lt https developer mozilla org en US docs Web Security Same origin policy
78. dy areas type ol interaction Modify A var modify Draw interaction to add a study area Qtype ol interaction Draw ay var draw Whether the study area has been modified by the user type integer Ey modified 0 Adds the relevant layers to the map param boolean firstLoad Whether layers are being loaded for the first time f function addLayers firstLoad Get sequential var seq parseInt seq val If editing or loading for first time and not adding if mode edit firstLoad amp amp mode add Define and add study area layer map removeLayer saLayer saSource new ol source GeoJSON url geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeN ame sde study area amp outputFormat application json amp cql filter id id H saLayer new ol layer Vector source saSource style saStyleFunction map addLayer saLayer If editing if mode edit Define and add quadrat count layer map removeLayer qcLayer qcSource new ol source GeoJSON url geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeN ame sde study area quadrat amp outputFormat application json amp viewparams id id 84 Juan Luis Rodas Rivera Technical Report qcLayer new ol layer Vector source gqcSource style qcStyleFunction H map addLayer
79. e obj getMinAccuracy obj getEps Sobj gt getMinPts obj getFrom format Y m d S obj getTimeUnit obj getTimeUnits echo lt div class form group div class col sm offset 3 col sm 2 button type button class btn btn default onclick saveEdits gt lt span class glyphicon glyphicon save gt lt span gt Save edits lt button gt lt div gt lt div gt lt form gt lt div gt lt div gt PHP_EOL break case explore Print quadrat count analysis dialogue printQuadratCounts Sconn pg_connect CONN_STRING Retrieve area of biggest cluster in this study area Sresultl pg query conn SELECT COALESCE MAX area 0 FROM cluster summary WHERE study area id S obj gt getId Smax_area pg fetch result resultl1 0 0 Print time slider echo Time slider gt PHP EOL lt div class panel panel default table id navigator gt lt tbody gt Sdata array Retrieve area of clusters for each time unit Sresult2 pg query conn SELECT seq area count FROM cluster summary WHERE study area id 0obj getId ORDER BY seq while Srow pg fetch row result2 Sdata Srow 0 area gt Srow 1 count gt Srow 2 pg_close Sconn First row contains the bar chart Srowl lt tr class bars Second row contains the cluster count Srow2 lt tr gt 70 Juan Luis Rodas Rivera Technical Report Third r
80. e implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details TI X Xo F You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt f require once dirname FILE vars php Class that represents a photo from Flickr copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera class photo The unique identifier of the photo var integer private Sid The unique idenfifier of the photo used by Flickr var string x private num Date the photo was added var string private dateAddeg Date the photo was taken var string private SdateTaken Declared accuracy of the photo var integer private Saccuracy 126 Juan Luis Rodas Rivera Technical Report Identifier of the user that uploaded the photo var string Rep private Suser Latitude of the location the photo was taken var real y private Slat Longitude of the location the photo was taken var real E private Slon Server farm where the photo is hosted var integer private farm Server where the photo is hosted var integer private Sserver Secret of the photo
81. e useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt require_once include vars php Script in charge of deleting a tag or a study area copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera x Retrieve identifier sent by the user Sid htmlspecialchars POST id Sconn pg connect CONN STRING switch htmlspecialchars POST type Delete study area rows dependent on this key from other tables will cascade case Study area pg delete conn study area id gt Sid break Delete tag rows dependent on this key from other tables will cascade case Tag pg delete conn tag id gt id Also delete photos related to the tag sql DELETE FROM photo WHERE id IN SELECT id FROM photo EXCEPT SELECT a id FROM photo a INNER JOIN photo tag b ON a id buaphgto 1d s pg query S conn sql break pg_close Sconn die 100 Juan Luis Rodas Rivera Technical Report ww overlaping clusters php php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public Licen
82. ea param string Stime_unit The new time unit public function setTimeUnit time unit if S Sthis time unit time unit this time unit time unit Sthis setTo Sthis upd time unit true Returns the number of time units in the study area return integer i public function getTimeUnits return this time units Sets the number of time units in the study area param integer time units The new number of time units public function setTimeUnits time units if S this time units time units this time units time units Sthis setTo Sthis upd time units true Returns the staring date of the timeframe param integer Sindex If specified returns the starting date of this time unit return DateTime ui public function getFrom index 0 Sfrom new DateTime this from for i 0 Si lt Sindex i Sfrom add S this getInterval return S from Sets the staring date of the timeframe param string from The new starting date of the timeframe public function setFrom Sfrom if Sthis from from Sthis gt from Sfrom Sthis gt setTo S this upd from true Returns the ending date of the timeframe param integer index If specified returns the ending date of this time unit 137 Juan Luis Rodas Rivera Technical Report return DateTime Kofe
83. en json Initiate polling to check for progress of update process var poll setInterval function Poll for progress update every 3333 ms S post action ww_poll_tag_update php tag tag When done done function data Update progress bar set progress data pct json bp 3933 3 Sets the value of the progress bar param real pct The value to set function set progress pct var bar update_progress Set aria value bar attr aria valuenow pct Set text bar first span text pct Set width bar css width pct Reduces the set of photos for a tag param integer tag The unique identifier of the tag xy function reduce_data tag Get cell that called the action var caller_rd rd_ tag Get button that called the action var btn caller rd find button Set button to loading state btn button loading Initiate AJAX request to reduce photos of this tag S post action ww_reduce_data php tag tag When done done function data Update list of tags with data returned S data caller prev text Yes data caller find span text data num Reset button state btn button reset Hide button btn addClass hidden json Calculates clusters for a study area 76 Technical Report Juan Luis Rodas Rivera Technical Report
84. en for the project PostgreSQL The GeoServer Project 2014b The great strength of GeoServer is the wide array of output formats that it supports KML JPEG PNG SVG GeoJSON and GML are among them The data exchange format used in the project is GeoJSON 2 2 1 GeoJSON GeoJSON is based on the JavaScript Object Notation JSON format a data exchange format published as the ECMA 404 standard ECMA International 2013 GeoJSON is a format specification to encode a series of geographic data structures as a JSON object Butler et al 2008 It supports the Point LineString Polygon MultiPoint MultiLineString MultiPolygon and GeometriCollection geometry types This format is used through the project for all queries from GeoServer since it is easily parsed by the JavaScript engines in modern browsers 23 Apache with PHP 5 The Apache HTTP Server together with PHP 5 are the technologies used to serve dynamic web pages by the tool PHP is used as a server module and is in charge of generating the web pages with the data retrieved from the database PHP provides functions to connect and query the PostgreSOL instance containing the application s tables and functions via a module which is enabled in the configuration file Juan Luis Rodas Rivera Technical Report 2 3 1 Phlickr Phlickr is an API kit written in PHP which connects to the REST endpoint of Flickr s web services and provides access to all the functionality exposed by the Flickr
85. er Sthis gt id pg fetch result pg query conn SELECT currval photo sd seg Oy 0 Associate the photo with the tag and with the data grab pg insert conn photo tag array photo id gt Sthis gt id tag id gt S tag getId pg insert conn grabbed photo array photo id gt Sthis gt id data grab id gt S dg gt getId else 1 Else retrieve its unique identifier S Sthis id sel 0 id Associate the photo with the tag if not already in database Ssell pg select conn photo tag array photo id gt Sthis gt id tag id gt S tag getId if Ssell 0 pg_insert Sconn photo tag array photo id gt Sthis id tag id gt S tag getId Associate the photo with the data grab if not already in database Ssel2 pg select conn grabbed photo array photo id gt this id data grab id gt dg gt getId if Ssel2 0 pg_insert Sconn grabbed photo array photo id gt Sthis gt id data grab id gt S dg gt getId pg_close Sconn Retrieves a list of photos that are within a specified distance and search criteria from this photo param real eps Search radius param tag tag Tag for which the neighbours are being searched param integer min accuracy Minimum accuracy of the neighbours param string geom Geometry to search within param string from Lower boundary of the timeframe param
86. etTo Sthis gt geom Sgeom Store the study area on the database function store Sconn pg connect CONN STRING Insert study area Ssql INSERT INTO study area tag id description quadrat size min accuracy eps min pts time unit Lime units timeframe from timeframe to geom VALUES S this 5tag getId Sthis gt description Sthis quadrat size S this min accuracy Sthis eps this min pts S this time unit Sthis time units S Sthis gt from Sthis to Sthis gt getGeom pg query conn sql Retrieve unique identifier Sthis id pg fetch result pg query conn SELECT currval study area id seq 0 0 pg close conn Updates the study area with changes made by the user Ayr function update Execute only if update is necessary if Sthis gt needsUpdate Build SQL update sentence Ssql UPDATE study_area SET if Sthis upd description sql sql description S this description if Sthis upd eps sql sql eps S this gt eps if Sthis gt upd_geom sql sql geom S this gt getGeom if Sthis gt upd_min_accuracy f Ssql sql min accuracy S this min accuracy if Sthis upd min pts Ssql sql min pts S this min pts if Sthis upd quadrat size sql sql quadrat size S this
87. ext S this getGeomAsWKT 4326 EPSG Returns the WKT representation of the location of the photo return string 128 Juan Luis Rodas Rivera Technical Report i public function getGeomAsWKT return POINT this lon this gt lat Class constructor Flickr photo F F ox if param string num The unique idenfifier of the photo used by param string integer dAdded Date the photo was added param string dTaken Date the photo was taken param integer Saccuracy Declared accuracy of the photo param string Suser Identifier of the user that uploaded the param real Slat Latitude of the location the photo was taken param real 10n Longitude of the location the photo was taken param integer Sfarm Server farm where the photo is hosted param integer server Server where the photo is hosted param string secret Secret of the photo param integer Sid The unique identifier of the photo function construct num dAdded dTaken accuracy user Slat Slon Sfarm Sserver Ssecret Sid 0 string 1 If the identifier was specified then assign it if Sid gt 0 Sthis gt id id Assign default values this num strval num Date added can be specified either as a Unix timestamp or a Sctl DateTime createFromFormat U SdAdded af bhsotl 4 Sthis gt dateAdded S dAdded else S
88. ext left gt span class label label info This time unit span id photo count class badge gt lt php echo Sobj getNumPhotos 0 gt lt span gt lt span gt AJ ulum Layer list lt div class col sm 4 text right 72 Juan Luis Rodas Rivera Technical Report lt div class btn group btn group xs data toggle buttons gt lt label class btn btn default active gt Base lt input type checkbox id layer0 checked checked gt lt label gt lt label class btn btn default active gt Study area lt input type checkbox id layerl checked checked gt lt label gt lt label class btn btn default gt Quadrats lt input type checkbox id layer2 gt lt label gt lt label class btn btn default active gt Clusters lt input type checkbox id layer3 checked checked gt lt label gt label class btn btn default active Photos lt input type checkbox id layer4 checked checked gt label lt div gt lt div gt lt php gt lt div gt dis lt Map gt lt div id map class map gt Popuo container for photo display gt lt div id popup class 0l popup gt lt div class panel panel default lt div class panel heading h3 class panel title gt lt span gt lt span gt small small h3 div lt div id popup content gt lt div gt lt div class panel footer gt lt small gt lt small gt lt but
89. g 0 Bi Mark each individual photo as part of the cluster 113 Juan Luis Rodas Rivera Technical Report foreach S this gt getPoints as point pg_insert Sconn cluster photo array cluster id gt Sthis gt id photo id gt S point 5getId pg close conn 114 Juan Luis Rodas Rivera Technical Report data_grab php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details F F HF x You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt xy require_once Phlickr Api php require_once dirname __FILE__ photo php require once dirname __FILE__ tag php require once dirname FILE vars php Class that represents a process of data downloading from Flickr copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera E class data_grab The unique iden
90. g l second Create DBSCAN object Sdoscan new dbscan_algorithm S this gt tag this gt min_accuracy Sgeom S from format Y m d H i s Sto format Y m d Hiss this eps this 2min pts gt Perform cluster calculation dbscan find clusters Add the number of cluster found n n dbscan getNumClusters Store clusters found in the database Sdbscan gt store Sthis gt id i Define lower boundary of the next time unit S Sfrom add interval 142 Juan Luis Rodas Rivera Technical Report Sconn pg_connect CONN_STRING Update study area pg_update Sconn study_area array calculated gt 1 updated gt now array id gt Sthis gt id pg_close Sconn return n Returns a copy of this study area for a new tag iparam tag new tag The tag to be used in the new study area return study area x public function copy new tag return new study area 0 new tag S this min accuracy Sthis eps S this time units S this gt from Sthis quadrat size Sthis mim pts thris otime unit S this geom 143 Juan Luis Rodas Rivera Technical Report tag php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later versi
91. he time unit for which to calculate the quadrat count It returns two attributes the identifier of the quadrat and the photo count on that quadrat The geometry type is Polygon The study_area layer publishes the table with the same name on the database It returns all the attributes that are part of this table The geometry type is Polygon The study_area_quadrat layer is also an SQL view defined on GeoServer that publishes the border of the area defined by the hexagonal quadrat grid for a study area It requires the identifier of the study area as a parameter The geometry type is Polygon 30 Juan Luis Rodas Rivera Technical Report 9 Web application structure The web application has four main web pages which can be accessed by the user index php viewer php manual php and license php The first gives the user access to the control panel where data maintenance and processing options can be accessed for tags study areas and clusters The second gives the user access to the viewer in which tempo spatial exploration and cluster analysis and validation options can be performed The third contains the user manual which has detailed instructions on how to use the application The fourth displays the license of the application On the root of the application there are also six directories which contain other files used by the main web pages to load content access the database and provide styling The root of the web application is
92. hen assign it if Sid gt D Sthis gt id id Sconn pg_connect CONN_STRING Retriev V alues for this study area result pg this id pg close conn select Sconn study area array id gt if count result 1 Sthis gt tag new tag Sresult 0 tag_id Sthis gt description result 0 description S this quadrat size Sresult 0 quadrat_size this min accuracy result 0 min_accuracy Sthis gt eps result 0 eps Sthis gt min_pts Sthis time unit Sresult 0 time_unit Sthis time units Sthis gt fr Sthis gt to Sthis gt ca Sthis gt up Use ge Swkb Sgeometry Sthis ge else Sresult 0 str_replace mon min pts month Sresult 0 time_units Sresult 0 timeframe_from Sresult 0 timeframe_to lculated Sresult 0 calculated dated Sresult 0 updated OPHP to read WKB geometry om new WKB Swkb gt read Sresult 0 geom Sgeometry gt asText TRUE om Assign values from the user Sthis gt tag Sthis description Sthis quadrat size tag Sdescription Squadrat_size 140 Juan Luis Rodas Rivera Technical Report Sthis gt min_accuracy min accuracy Sthis gt eps Seps Sthis gt min_pts min pts Sthis gt time_unit Stime_unit this time units time units Sthis gt from Sfrom Sthis gt s
93. his min accuracy min accuracy Sthis min accuracy min accuracy S this upd min accuracy true 135 Technical Report Juan Luis Rodas Rivera Returns the search radius for neighbours on the DBSCAN algorithm return real public function getEps return S this eps Sets the search radius for neighbours on the DBSCAN algorithm new eps param real Seps Th if public function setEps Seps if Sthis gt eps Seps Sthis gt eps Seps true S Sthis upd eps ur 1 inumu u E O yin r u r or Returns the minumum number of points to create a cluster on the DBSCAN algorithm return integer public function getMinPts return Sthis gt min_pts of points to create a cluster on the Sets the minumum number The new min pts f public function setMinPts min pts Sthis min pts min pts Sthis min pts min pts S this upd min pts true DBSCAN algorithm param integer S min pts if study area as an interval Returns tthe time unit used on the x return DatelInterval y private function getInterval return DateInterval createFromDateString S this time unit return string ud public function getTimeUnit return this time unit Returns the time unit used on the study area 136 Juan Luis Rodas Rivera Technical Report Sets the time unit used on the study ar
94. hoto tag b ON a id b photo id WHERE b tag id a tag id AND a usr fl usr AND a date taken date fl date taken ORDER BY a accuracy DESC distance FETCH FIRST ROW ONLY LOOP INSERT INTO filtered photo VALUES f2 id END LOOP END IF END LOOP Set dataset as reduced UPDATE data grab SET reduced 1 WHERE tag id a tag ig Return the number of photos in the reduced dataset RETURN i END LANGUAGE plpgsql Returns all clusters that overlap clusters up to two time units before and after of the specified sequence CREATE OR REPLACE FUNCTION cluster neighboors a id integer a seq integer RETURNS TABLE id integer seg delta integer geom geometry AS DECLARE 53 Juan Luis Rodas Rivera Technical Report fl record Outer loop all clusters in the specified sequenc f2 record Inner loop all the clusters that intersect BEGIN Loop through all clusters in the specified sequence FOR f1 IN SELECT a id a geom FROM cluster a WHERE a study area id a id AND a seq a seq LOOP Loop from two time units before to two time units after the Specified sequenc FOR i IN 2 2 LOOP Return current cluster if 0 IF i 0 THEN RETURN QUERY SELECT fl id i fl geom CONTINUE END IF Return all the clusters that intersect FOR f2 IN SELECT a id a geom FROM cluster a WHERE a study area id a id AND a seq a seq i AND ST Intersects fl geom a geom LOOP RETURN QUERY SELECT f2 id i f2 ge
95. icense along with this program If not see lt http www gnu org licenses gt require_once include tag php Script in charge of performing data insertion and update for tags copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera a If tag name sent then insert new tag if array key exists tag POST Retrieve the name of the tag to insert and insert it Stag new tag 0 htmlspecialchars POST tag Redirect to main page header Location index php If tag identifier sent then perform update of photos for this tag elseif array key exists id POST require once include data grab php Retrieve the identifier of the tag to update Stag new tag htmlspecialchars POST id Create a new data grab object dg new data grab tag Retrieve new phtoso from Flickr Sdg gt grab Return data on the photos downloaded in JSON format header Content Type application json echo json encode array caller pu_ dg gt getTag gt getId tag id gt S tag getId count gt dg gt getNPhotos updated gt dg getEnded JSON PRETTY PRINT die 111 Juan Luis Rodas Rivera Technical Report Appendix G PHP code for the files in the include folder cluster php php This program is free software you can redistribute it and or modify it under the term
96. id study area row 0 Cclass study area tag row 2 td class text right row 0 td td S row 1 td td S row 3 td td class text right gt Srow 4 lt td gt lt td class text right gt row 5 lt td gt lt td class text right gt Srow 6 lt td gt lt td class text right gt Srow 7 lt td gt lt td gt S row 8 lt td gt lt td class text right gt Srow 9 lt td gt lt td class text right gt Srow 10 lt span class label label info gt to lt span gt row 11 lt td gt lt td class text right gt row 12 lt td gt lt td class text right id cl_ row 0 gt clusters lt td gt lt td gt lt button type button class btn btn sm btn default btn block onclick explore row 0 span class glyphicon glyphicon globe gt lt span gt lt button gt lt td gt lt td gt lt button type button class btn btn sm btn default btn block onclick edit row 0 span class glyphicon glyphicon pencil gt lt span gt lt button gt lt td gt lt td gt lt button type button class btn btn sm btn default btn block onclick del Study area row 0 Srow 1 gt lt span class glyphicon glyphicon trash span button td tr PHP EOL tbody table dise 1 Add study area section div id add study area class panel panel default lt div class panel panel heading lt h
97. ion done Get time of ending Sthis gt ended new DateTime In cases where there are no photos to download the start and end time can be the same if Sthis gt ended this gt started Add a second to end time to make it different from start time Sthis gt ended gt add DateInterval createFromDateString 1 second y gt Sconn pg_connect CONN_STRING Store time of ending pg_query Sconn UPDATE data grab SET ended S this gt getEnded WHERE id S this gt id Retrieve number of photos downloaded Sthis n photos pg_fetch_result pg_query Sconn SELECT COUNT FROM photo tag WHERE tag id this gt tag gt getId 0 0 pg close conn 119 Juan Luis Rodas Rivera Technical Report dbscan_algorithm php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by ct he Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details F F HF x You should have received a copy of the GNU General Public License along with this program If not see lt http w
98. is Rodas Rivera Technical Report E public function getStarted return this 5started format Y m d H i s Returns the time at which the download process ended return string ui public function getEnded return this ended format Y m d H i s Returns the total number of photos actually downloaded return integer di public function getNPhotos return S this n photos Class constructor param tag Stag Tag for which the data is being downloaded Ay function __construct Stag Define Flickr API parameters Sthis gt api new Phlickr_Api FLICKR_API_KEY FLICKR_API_SECRET Assign initial values Sthis gt tag tag Sthis page 1 Sthis gt started new DateTime These are the default parameters used when searching for photos on Flickr Sthis gt parms array tags gt Sthis 5tag getName min upload date gt Sthis gt getMinUploadDate max upload date gt this getStarted sort gt date posted asc has geo gt 1 extras gt date upload date taken geo per_page gt 250 page gt Sthis page min taken date gt 2000 01 01 00 00 00 Get data on the search from Flickr Srsp Sthis gt api gt ExecuteMethod flickr photos search Sthis parms Store information retrieved from Flickr Sthis gt total intval rsp xml photos total Sthis pages intval rsp xml photos pages
99. is configured to perform cascaded deletes The geom attribute is spatially indexed to improve query performance 18 Juan Luis Rodas Rivera Check constraints are included for the following attributes 6 1 8 The quadrat size eps and time units attributes to only allow values greater than zero The min accuracy attribute to only allow values between 1 and 16 The min pts attribute to only allow values greater than one The time unit attribute to only allow intervals greater than one day The timeframe from and updated attributes to only allow values greater or equal than January 1 2000 The timeframe_to attribute to only allow values greater than the timeframe from attribute The calculated attribute to only allow either 0 or 1 Boolean Table cluster The table cluster stores the clusters found by the DBSCAN algorithm for each study area It has the structure shown on Table 8 Table 8 Structure of table cluster Attribute Data type Allow nulls Description id serial No Unique identifier study area id integer No Identifier of the study area on which seq geom the cluster was found integer No Sequential number of the time unit on which the cluster was found geometry No Spatial extent of the cluster area of POLYGON influence of the core points 3857 The id attribute is the primary key of the table and is auto incremental The study area id attribute is a foreign key to the table study are
100. ithout even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt ul require once include vars php Script in charge of sending updates on the progress of a tag update process copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera A Retrieve identifier of the tag Sid htmlspecialchars POST tag Retrieve update status from the database Sconn pg connect CONN STRING result pg query conn SELECT a total COUNT b photo id FROM data grab a LEFT OUTER JOIN grabbed photo b ON a id b data grab id WHERE a tag id id AND a latest 1 GROUP BY a total pct 0 If update in progress if pg num rows result gt 0 Calculate progress Stotal pg fetch result result 0 0 if Stotal gt 0 Sactual pg fetch result result 0 1 Spct round 100 Sactual total 2 pg close conn Return the percentage of progress in JSON format header Content Type application json echo json encode pct gt pct JSON PRETTY PRINT die 104 Juan Luis Rodas Rivera Technical Report ww_quadrat_counts php lt php This program is free software you
101. ivera Technical Report DELETE FROM cluster WHERE id IN SELECT a id FROM cluster a INNER JOIN study_area b ON a study_area_id b id WHERE b tag_id a_tag_id Set all study areas for this tag as not calculated UPDATE study area SET calculated 0 updated now WHERE tag id a tag id Loop through every unique pair of user and date taken FOR f1 IN SELECT DISTINCT a usr a date taken date COUNT AS count FROM photo a INNER JOIN photo tag b ON a id b photo id WHERE b tag id a tag id GROUP BY a usr a date taken date LOOP i i 1 If there is only one photo insert it in the filtered list IF fl count THEN INSERT INTO filtered photo SELECT a id FROM photo a INNER JOIN photo tag b ON a id b photo id WHERE b tag id a tag id AND a usr fl usr AND a date taken date fl date taken ELSE a x a_y 0 j 0 Else add the x and y coordinates of each photo FOR f2 IN SELECT ST X a geom AS x ST Y a geom AS y FROM photo a INNER JOIN photo tag b ON a id b photo id WHERE b tag id a tag id AND a usr fl usr AND a date taken date fl date taken LOOP j 9 a x a_y END LOOP Get the averag ax a_x j a_y ay j Insert the photo located closest to the average to the li o Tubs a x 2 x a y f2 y Hl c filtered list FOR f2 IN SELECT a id ST Distance a geom ST GeomFromText POINT a x II Ill ay Il 3857 AS distance FROM photo a INNER JOIN p
102. l be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details F X X You should have received a copy of the GNU General Public License along with this program If not see http www gnu org licenses oa A require_once include study_area php Script in charge of calculating the clusters for a study area copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera uf Calculate clusters for the study area specified by the user study area new study area htmlspecialchars POST study area num study area calculate Return the number of clusters calculated in JSON format header Content Type application json echo json encode array caller gt cl S study_area gt getId study area id gt S study area 5getId num gt num JSON PRETTY PRINT die 99 Juan Luis Rodas Rivera Technical Report ww_delete php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by ct he Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will b
103. l php Manual a li lt li gt lt a href license php gt License lt a gt lt li gt srul lt div gt dise lt faiv gt Container for delete confirmation div class modal fade id 2 delete confirmation tabindex role dialog aria labelledby modalLabel aria hidden true gt lt div class modal dialog modal sm gt lt div class modal content gt lt div class modal header lt button type button class close data dismiss modal span aria hidden true gt amp times lt span gt lt span class sr only gt Close lt span gt lt button gt lt h4 class modal title id modalLabel gt Confirm deletion lt h4 gt lt div gt lt div class modal body gt lt p gt Are you sure you want to delete lt p gt us lt span id del type class label label info gt lt span gt lt span id del_id gt lt span gt small id del_desc gt lt small gt lt h5 gt lt div gt lt div class modal footer gt lt button type button class btn btn default data dismiss modal gt No lt button gt lt button type button class btn btn danger data dismiss modal onclick del_db gt Delete lt button gt lt div gt lt div gt lt aiy gt lt div gt Main body container gt div class container gt php require once include vars php require once Phlickr Api php Create Phlickr object Sapi new Phlickr Api FLICKR API KEY FL
104. lank gt Complete lt a gt lt div gt lt td gt lt td gt lt button type button class btn btn sm btn default btn block onclick del Tag Srow 0 Srow 1 gt lt span class glyphicon glyphicon trash gt lt span gt lt button gt lt td gt lt tr gt PHP EOL ct BN il gt lt tbody gt lt table gt lt div class panel footer gt lt div class row gt lt div class col md 5 text left gt lt small gt Note Updating a tag may take a long time please don t reload the page lt small gt lt div gt lt div class col md 7 text right lt div class progress hidden gt lt div id update_progress class progress bar progress bar info progress bar striped role progressbar aria valuenow 0 aria valuemin 0 aria valuemax 100 style width 0 gt lt span gt 0 lt span gt ey aq e fdas lt faix gt lt div gt f dives 62 Juan Luis Rodas Rivera Technical Report dis Add tag section lt div id add tag class panel panel default div class panel panel heading lt h2 class panel title gt lt span class glyphicon glyphicon tag gt lt span gt Add a tag lt h2 gt lt div gt lt div class panel body gt lt form action action ww_tag php method post role form class form horizontal gt lt div class form group gt label for tag name class col sm 1 control label gt Tag lt label gt div class
105. le Style var styleFunction function feature resolution Set radius of point according to the resolution var radius 3 if resolution lt 3500 radius 4 else if resolution lt 1500 radius 5 else if resolution lt 500 radius 6 Retrieve style from style cache var style styleCache radius If style does not exist create it if style 79 Juan Luis Rodas Rivera Technical Report Create new style style new ol style Style image new ol style Circle radius radius fill new ol style Fill colos egba 255 D 0 1 stroke new ol style Stroke color sgb lzb55 2595 255 L width 1 l Add it to style cache styleCache radius style Return the style return style Style cache for polygons in the cluster layer type array var clusterStyleCache Style function for polygons in the cluster layer param ol Feature featur param real resolution returns ol style Style 7 var clusterStyleFunction function feature resolution Get sequential delta from feature var delta feature get seq delta Retrieve style from style cache var style clusterStyleCache delta If style does not exist create it if style Set colours and stroke according to the sequential delta wer Till sgba 255 255 1291 0 7 7 var stroke 708090 var lineDash
106. led by GeoServer on the server side Since Apache Tomcat runs on a different port than the Apache web server a request from the browser to retrieve information in JSON format from Tomcat would be considered a cross domain request and would be in violation of the browser s same origin policy Mozilla Developer Network 2014b To get around this problem all calls to GeoServer on Tomcat need to be proxied through a virtual host on Apache This architecture is shown on Figure 1 Clients Figure 1 Architecture used by the tool Juan Luis Rodas Rivera Technical Report 4 Requirements and assumptions The purpose of the tool as described in Rodas Rivera 2014 is to use photos from Flickr as a source of geographical information and perform spatial and temporal querying and analysis on these datasets with this in mind the following requirements and assumptions were defined prior to the development of the tool REQ 01 The tool must let the user define a set of tags to be retrieved from Flickr REQ 02 The tool must be able to connect to Flickr query photos for a particular tag and store relevant information relating these photos REQ 03 The tool must simplify the dataset of photos filtering out those taken by the same user on the same day on the same location REQ 04 Spatial and temporal analysis must be performed on top of the reduced datasets REQ 05 The tool must let the user define a set of study areas for a particular
107. llowed to allow Phlickr to communicate to the new Flickr API REST endpoint 1 Go to the directory where Phlickr was installed either in the directory where PHP was installed or in a subdirectory there called PEAR 2 Open the file Request php 3 Look for the submitHttpPost function 4 Onthe second line of this function after the declaration of the variable ch add the following curl_setopt ch CURLOPT SSL VERIFYPEER false 5 Save the file 6 Open the file Api php 7 Look for the constant called REST ENDPOINT URL and change its value to 40 Juan Luis Rodas Rivera Technical Report const REST ENDPOINT URL https api flickr com services rest 8 Save the file This will complete the configuration and installation of Phlickr Apache needs to proxy all calls made to GeoServer this is because calls from Apache to GeoServer are considered by the browser as cross domain request and thus are blocked by the browser s same origin policy To configure Apache to proxy calls made to GeoServer the following modules need to be enabled on Apache s httpd conf configuration file e proxy module e proxy http module e headers module e deflate module e xml2enc module e proxy html module Also add the following block of text to the end of Apache s httpd conf configuration file lt VirtualHost 80 ProxyPass GeoServer http localhost 8080 GeoServer ProxyPassReverse GeoServer ht
108. n This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt af Footer used on the application web pages copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera wy gt footer lt div class container gt lt div class well well sm text center gt lt img src img ed png alt University of Edinburgh lt h6 gt School of Geosciences lt h6 gt lt h6 gt Dissertation for the degree of lt h6 gt lt h6 gt lt strong gt MSc in Geographical Information Science lt strong gt lt h6 gt h6 strong Juan Luis Rodas Rivera lt strong gt lt h6 gt h6 August 2014 h6 sy de fdive lt footer gt 125 Juan Luis Rodas Rivera Technical Report photo php lt php Te This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even th
109. n class sr only Toggle navigation lt span gt span class icon bar span span class icon bar gt lt span gt span class icon bar gt lt span gt 66 Juan Luis Rodas Rivera Technical Report lt button gt lt a class navbar brand href gt lt span class glyphicon glyphicon globe gt lt span gt Tempo spatial explorer of Flickr tags lt a gt lt div gt lt div class collapse navbar collapse gt lt ul class nav navbar nav gt lt li gt lt a href index php study_areas gt Control panel lt a gt lt li gt lt li class active gt lt a href gt Map explorer lt a gt lt li gt Eee href manual php explore gt Manual lt a gt lt 1li gt lt li gt lt a href license php gt License lt a gt lt li gt lt ul gt lt div gt lt div gt lt div gt Main body container lt div class container gt lt php require_once include study_area php require once include tag php Retrieve mode to initialise the viewer Smode htmlspecialchars POST mode Page header gt div class page header lt h4 gt lt span class glyphicon glyphicon map marker gt lt span gt amp nbsp lt php Print page header depending on the mode switch Smode case add Sobj new tag htmlspecialchars _POST id echo lt small gt Add lt small gt study area lt small gt for tag lt small gt 0obj getName break case explore ca
110. n one process if new photos are being obtained for an existent tag but a single download process can perform photo downloads for only one tag A tag can also have multiple study areas associated with it but a particular study area can only refer to one tag The study area entity has a one to many relationship with the cluster entity besides the one to many relationship defined above A study area can have multiple clusters associated with it but a particular cluster can only belong to one study area These relationships are shown on the E R diagram on Figure 7 10 Juan Luis Rodas Rivera Technical Report Cluster Belongs to N M M 1 Photo Study area M M Downloaded by Tagged by Belongs to N 1 M 1 Data grab Belongs to Tag Figure 7 Entity relationship diagram for the application 5 3 Domains All entities defined earlier use an auto increment integer as identifier which is declared as serial data type in PostgreSOL this was selected mostly for simplicity when inserting new records The photo entity could potentially use the photo id assigned by Flickr as an identifier but although it is unique for every photo its data type is bigint which uses twice the storage size of a regular integer 8 bytes vs 4 bytes PostgreSQL Global Development Group 2014a Fields which store integer numbers are divided in three data types bigint used above for Flickr
111. nload for a particular tag and another is used to denote a particular data set which has been reduced The data grab entity and its attributes are shown on Figure 4 a Process start e Data grab Is latest ES Process end m Vii number of photos Is reduced NN Figure 4 Data grab entity and its attributes Juan Luis Rodas Rivera Technical Report 5 1 4 Study area entity This entity represents a location in space and time related to a particular tag that will be analysed in the search for clustering and possible relationships in the data A study area has a textual description that identifies it and exists in both spatial and temporal extents The spatial extent comprises the geometry object drawn by the user defining the boundaries of the study region The temporal extent comprises a timeframe with start and end dates a time unit and the number of time units in the timeframe The study area also keeps information on the parameters needed to search for the clusters the maximum distance and the minimum number of points The quadrat size is also stored in the study area Finally a timestamp is used to keep track of the last modification made to a study area The study area entity and its attributes are shown on Figure 5 a Description X Study area Date last updated N Cluster analysis mm Spatial extent MY Timeframe temporal mes
112. nnerHTML lt img src https farm feature get farm staticflickr com feature get server feature get num feature get secret m jpg alt Preview gt Display photo preview container container style display block Set date of the photo taken popup content next find small text feature get date_taken If clicked on a cluster else if action show_overlaping_clusters Send AJAX request to retrieve other time units with clusters that overlap this cluster post action ww_overlaping_clusters php sa id id feature get id When done done function data Clear styling on second row of time slider S seq_count_0 parent children removeClass Reset bar chart resetBars Loop through each time unit with cluster that overlap for var a id in data Set cell background S 4seq count data a id 0 addClass overiaps Replace standard bars for var i 0 i lt data a_id 1 fseq area data a_id l i 0 img first remove seq_area_ data a id 0 append img class overlap src img bar2 png alte bar fx json Set map to listen for clicks from the user Auf 93 Juan Luis Rodas Rivera map on click function evt mapClicked evt pixel evt coordinate x F Execute once the DOM has finished loading
113. oPHP 32 Juan Luis Rodas Rivera Technical Report The js and css folders contain the JavaScript and CSS scripts used by the main web pages to provide styling and interactivity These folders also contain the files needed for the jQuery Bootstrap and OpenLayers 3 libraries The structure of the files on these folders is shown on Figure 17 css lt gt index css viewer css ss ol css bootstrap css bootstrap theme css TE re E ME Em ili i Vp i d VE VE dl M il Wt Hl Figure 17 Structure of the js and css folders within the web application The img folder contains the images used on the web application this include the images used on the creation of the bar chart for temporal analysis of clusters The fonts folder contains Bootstrap s glyphicons used by the web application on the main web pages to show importance in some headers 33 Juan Luis Rodas Rivera Technical Report 10 Installation The tool is provided in the accompanying DVD in two formats source code that can be deployed on a web server with the correct set up and as a virtual machine that can be run straight from a computer by installing VirtualBox The procedure to install and run the software for both of these scenarios is described in this section 10 1 Full install The full installation should be performed when the tool is going to be
114. of a vertex in a hexagon a y double precision y coordinate of a vertex in a hexagon a quadrat geometry Geometry object of a hexagon a width double precision Width of all hexagons a height double precision Height of all hexagons a vert double precision Vertical spacing between adjacent hexagons a horiz double precision horizontal spacing between adjacent hexagons a wkt text Stores the WKT representation of a hexagon a lst point text Stores the WKT representation of the first point in a hexagon needed to close the polygon i integer 0 Incremental counter which gives each hexagon an id r integer 0 Incremental row counter a_offset double precision Offset to add to odd rows BEGIN Get data on the study area particularly the coordinates of the two defining points of the bounding box min and max x and y FOR f1 IN SELECT ST X ST StartPoint ST ExteriorRing ST Envelope a geom AS min x ST Y ST StartPoint ST ExteriorRing ST Envelope a geom AS min y ST X ST PointN ST ExteriorRing ST Envelope a geom 3 AS max x ST Y ST PointN ST ExteriorRing ST Envelope a geom 3 AS max y a quadrat size a geom FROM study area a WHERE a id a id LOOP Formulas for this function where taken from Hexagonal Grids by Red Blob Games http www redblobgames com grids hexagons The length of a side of a hexagon is equal to the radius of the b
115. ol layer Vector source clusterSource style clusterStyleFunction visible S layer3 is checked map addLayer clusterLayer Define and add photo layer map removeLayer photoLayer 85 Juan Luis Rodas Rivera Technical Report Set geometry condition to filter photos var geomCondition 20AND 20WITHIN geom geom If adding do not use condition if mode add geomCondition photoSource new ol source GeoJSON url geoserver geoserver sde ows service WFS amp version 1 0 0 amp request GetFeature amp typeN ame sde photo reduced amp outputFormat application json amp cql filter tag id tag id 20AND 20accuracy min acc geomCondition S20AND 20date_taken 20DURING 20 times seq 0 times seq 1 photoLayer new ol layer Vector source photoSource style styleFunction visible S layer4 is checked mode explore map addLayer photoLayer If adding and loading for the first time if mode add amp amp firstLoad Define and add feature overlay for study area drawing featureOverlay new ol FeatureOverlay style new ol style Style fill new ol style Fill olor rgba 255 255 255 0 2 stroke new ol style Stroke color ffcc33 width 2 image new ol style Circle radius 7 fill new ol style Fill color ffco33 featureOverlay setM
116. om END LOOP END LOOP END LOOP END LANGUAGE plpgsql Returns whether clusters on a specified sequence of a study area have overlapping clusters in another sequence defined by a delta CREATE OR REPLACE FUNCTION clusters overlap a id integer a seq integer a delta integer RETURNS integer AS 5 DECLARE fl record Outer loop all clusters in this sequence f2 record Inner loop all clusters in the delta sequenc BEGIN Loop through all clusters in this sequence FOR f1 IN SELECT geom FROM cluster WHERE study area id a id AND seq a seq LOOP Loop through all clusters in the delta sequenc FOR f2 IN SELECT geom FROM cluster WHERE study area id a id AND seq a seq a delta LOOP If one of them intersect then return 1 IF ST Intersects fl geom f2 geom THEN RETURN 1 END IF END LOOP END LOOP Return 0 if none overlap RETURN 0 END LANGUAGE plpgsql Creates a hexagonal grid beehive that fills the specified study area and returns it as a set of geometries 54 Juan Luis Rodas Rivera Technical Report CREATE OR REPLACE FUNCTION study area as hex quadrat a id integer RETURNS TABLE id integer geom geometry AS DECLARE fl record Stores data on the study area a cx double precision x coordinate of the centre of a hexagon a cy double precision y coordinate of the centre of a hexagon a x double precision x coordinate
117. on This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details TI F F Xo x You should have received a copy of the GNU General Public License along with this program If not see http www gnu org licenses f require once dirname FILE vars php Class that represents a of tag copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera a class tag The unique identifier of the tag var integer private Sid The name or description of the tag var string x private name Returns the unique identifier of the tag return integer f public function getId return this gt id Returns the name or description of the tag return string f public function getName return this gt name 144 Juan Luis Rodas Rivera Technical Report Class constructor param integer The unique identifier of the tag param string The name or description of the tag 24 function _ construct Sid Sname null Sconn pg connect CONN STRING If the identifier is specified then retrieve the name from the database if Sid gt D Sthis gt id id result pg select conn tag arra
118. ounding circle quadrat size These are pointy topped hexagons The height of the hexagon is equal to the length of a side times 2 a height fl quadrat size 2 The width of the hexagon is equal to the square root of 3 times the height divided by 2 a width 3 a height 2 The vertical spacing between adjacent hexagons is 3 4 the height a vert 0 75 a height The horizontal spacing between adjacent hexagons is the width of a hexagon a horiz a width Start at the lower corner of the bounding box a cy fl min y Repeat while the centre of the hexagon is within the bounding box plus an offset WHILE a cy lt fl max y a height 2 LOOP If the row is odd then add an offset to the centre of the x coordinate IF r 2 0 THEN a_offset 0 ELSE 55 Juan Luis Rodas Rivera Technical Report a_offset a_width 2 END IF a Cx fl min x a offset Repeat while the centre of the hexagon is within the bounding box plus an offset WHILE cx lt fl max x a width 2 LOOP Increase hexagon count i s i I Build WKT for the hexagon POLYGON a_wkt POLYGON Vertexes of pointy topped hexagons start at 30 up to 330 in increases of 60 FOR angle IN 30 330 BY 60 LOOP Calculate position of the vertex a x a cx fl quadrat size cos pi angle 180 a y a cy fl quadrat size sin pi angle 180 Add to WKT a wkt
119. ow contains the year referenc S row3 lt tr gt Colspan for row 3 elements Sk 1 Get first year Scurrent_year Sobj gt getFrom 0 gt format Y Build rows by looping through all time units for Si 0 i lt obj getTimeUnits i First row Srowl Srowl lt td id seq area i onclick move Si gt If there are clusters in this time unit if array key exists i Sdata Calculate relative siz pct area 10 data S i area max area Print bar chart for j 0 j lt pct area S j Srowl rowl lt img src img bar png alt bar class bar gt Second row Srow2 Srow2 lt td id seq_count_ Si oncLlick move Si 3 S Sdatalsi count lt 7tas If there are no clusters set default values else Srowl Srowl lt img src img blank png alt bar elass bar f Srow2 Srow2 lt td id seq count i onclick move i gt amp middot lt td gt Srowl Srowl lt td gt Get year of next time unit Snew_year obj getFrom i 1 2tormat Y y If different from current year if Scurrent year new year Add an extra CSS class when the cell is the first or last in the row Sextra class if S row3 tr Sextra_class first elseif Si obj getTimeUnits 1 Sextra_class last Third row Srow3 Srow3 lt td class year
120. p 0 01 value quad_size required required az aiy echo lt label for sa_min_accuracy class col sm 1 gt Minimum accuracy lt label gt echo lt div class col sm 2 input type number name min accuracy id sa_min_accuracy class form control min 1 max 16 step 1 value min_acc required required Is 7o01u 045yvs Prints the inputs that contain the DBSCAN clustering algorithm parameters echo lt div class form group gt lt span class col sm 2 label label info gt DBSCAN clustering parameters lt span gt lt label for sa eps class col sm 1 control label gt eps lt label gt 68 Juan Luis Rodas Rivera Technical Report echo lt div class col sm 2 input type number name eps id sa_eps class form control min 1 max 999999999 step 0 01 value eps required required gt lt div gt echo lt label for sa min pts class col sm 2 control label min pts lt label gt echo lt div class col sm 2 input type number name min pts id sa min pts class form control min 2 max 999999999 step 1 value S min pts required required gt lt j Giv gt lt div gt Prints the inputs that contain the timeframe definition echo lt div class form group span class col sm 2 label label info gt Timeframe definition lt span gt lt label for sa timeframe from class col sm 1 control label gt From lt label gt echo div class col sm
121. port associated photo count The structure of the output generated by the quadrat_count function is shown on Table 17 Table 17 Structure of the output of function cluster_neighbours Attribute Data type Description id integer Identifier of the quadrat count bigint Number of photos in the quadrat geom geometry Spatial extent of the hexagonal quadrat POLYGON 3857 26 Juan Luis Rodas Rivera Technical Report 7 Classes PHP is the server side language chosen to develop the web application Although PHP is a scripting language it contains support for object oriented programming The PHP Group 2014 Six classes were created to build the logic of the application Five of them represent the entities defined on the database design section and provide direct access to data storage and retrieval with their respective tables The last class is an implementation of the DBSCAN clustering algorithm for cluster analysis The code for the classes together with a complete description and documentation on each of the classes attributes and functions is included in Appendix G Class diagrams for the six classes are shown on Figures 9 to 14 Saccuracy int SdateAdded string SdateTaken string Sfarm int id int Slat float Slon float Snum string Ssecret string Sserver int Suser string getAccuracy int getDateAdded string getDateTaken string getFarm int getGeom string
122. public function getTo Sindex NULL if is_null Sindex xor Sindex S this gt time_units return new DateTime Sthis gt to else return Sthis gt getFrom Sindex 1 sub DateInterval createFromDateString l second Calculates and sets the ending date of the timeframe Ry private function setTo to clone this gt getFrom for i 0 i lt this gt time_units i to gt add this gt getInterval to gt sub DateInterval createFromDateString 1 second Sthis gt to to gt format Y m d H i s Returns whether clusters in the study area have been calculated return integer xj public function getCalculated return S this calculated Returns the date of the last update made to the study area return string aad public function getUpdated return S this updated Returns the geometry of the study area return string public function getGeom return ST GeomFromText S this geom EPSG Sets the geometry of the study area param string geom The new geometry public function setGeom Sgeom Sthis gt geom Sgeom S this upd geom true Returns the geometry of the study area as WKT return string A public function getGeomAsWKT 138 Juan Luis Rodas Rivera Technical Report return Sthis gt geom Returns the geometry of the quadrats
123. r overlapping clusters and outputs one when there are overlapping clusters or zero otherwise 6 3 4 Function study area as hex quadrat This function creates a hexagonal grid beehive that fills the specified study area without overlapping on the borders The length of the sides of each hexagon is equal to the value entered for quadrat size by the user on the study area The origin of the grid is located on the lower corner of the bounding box of the study area A hexagonal grid was selected for the application since it proved to full arbitrary shaped non rectangular study areas better than regular square grids The function receives the identifier of the study for which to build the hexagonal grid and outputs the list of hexagons that make up the grid The structure of the output generated by the study area as hex quadrat function is shown on Table 16 Table 16 Structure of the output of function study area as hex quadrat Attribute Data type Description id integer Identifier of the quadrat geom geometry Spatial extent of the hexagonal quadrat POLYGON 3857 6 3 5 Function quadrat count This function calculates the number of photos that fall within each quadrat in a specified study area and time unit The function receives the identifier of the study area and the sequential of the time unit for which to calculate the quadrat count and outputs the list of quadrats with their 25 Juan Luis Rodas Rivera Technical Re
124. rameters from as specifies by the user sa setDescription htmlspecialchars POST description sa setEps htmlspecialchars POST eps sa setFrom htmlspecialchars POST from 109 Juan Luis Rodas Rivera Technical Report Check if geometry was modified if htmlspecialchars POST upd geom gt 0 sa setGeom htmlspecialchars POST geom sa setMinAccuracy htmlspecialchars POST min accuracy sa setMinPts htmlspecialchars _POST min_pts sa setQuadratSize htmlspecialchars POST quadrat size sa 5setTimeUnit htmlspecialchars POST time unit sa setTimeUnits htmlspecialchars POST time units Update the study the area sa update 110 Juan Luis Rodas Rivera Technical Report ww_tag php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public L
125. res where 6 decimal digits would mean a precision of up to a micrometre In the case of the coordinates of photos the latitude is restricted to values between 90 and 90 and the longitude to values between 180 and 180 all other fields which store decimal numbers are restricted to values greater than zero Fields which contain textual descriptions for entities like the tag name or the study area description will be declared as variable length character fields with a length limit of 50 characters A user id on Flickr can have up to 15 alphanumeric characters The secret for each photo is a fixed length string of 10 characters Fields which refer to dates will use the timestamp data type and will be limited to dates greater or equal to January 1 2000 When an entity has two fields referring to dates such as a start and an end date the end date must be greater than the start date The field used for defining the time unit on the study area entity will use an interval data type and will allow values greater or equal to one day thus the minimal time unit that the application will allow to be used in cluster calculations is one day 12 Juan Luis Rodas Rivera Technical Report 6 Physical database 6 1 Tables This section describes the physical database tables that where created based on the entity relationship model described on the last section The physical database diagram used by the application is shown on Figure 8 The scrip
126. right gt 0 20 lt th gt lt th class text right 0 10 th th class text right gt 0 05 lt th gt lt th class text right 0 025 th th class text right gt 0 02 lt th gt lt th class text right 0 01 th th class text right gt 0 005 lt th gt lt th class text right 0 002 th th class text right gt 0 001 lt th gt lt tr gt thead tbody SEE php for Si Q Si lt Tilly i echo lt td class text right gt Slookup Stotal 1 i lt td gt gt lt tr gt lt tbody gt lt table gt lt php If there are no photos on this study area and time unit display a message accordingly else gt div class panel body gt lt h4 gt lt span class label label warning gt There are no photos on this time unit lt span gt lt h4 gt diy php die 107 Juan Luis Rodas Rivera Technical Report ww reduce data php php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You sho
127. rn array merge S this points S this density reachable Class constructor my function __construct Sthis points array S this density reachable array Adds a photo to the cluster param photo point The point to add param boolean density reachable Whether the point is density reachable or not ay function add Spoint density reachable FALSE if Sdensity_reachable array push this density reachable Spoint eise array push S this points Spoint Stores the cluster on the database param integer Sid Id of the study area to which the cluster belongs param integer seq Sequential number of the cluster in the timeframe param real eps Distance used by the buffer function to create the cluster Ey function store Sid Sseq Seps Retrieve all the id s of the photos which are part of the cluster Spoint_ids foreach S this gt points as Spoint Spoint_ids Spoint_ids point 5getId point ids rtrim point ids Sconn pg connect CONN STRING Use union together with buffer to create th xtent of the cluster Ssql INSERT INTO cluster study area id seq geom SELECT Sid seq ST Union ST Buffer geom Seps FROM photo WHERE id IN porut rds jrVr pg query conn sql Retrieve the id of the cluster Sthis gt id pg fetch result pg query conn SELECT c rrval coluster id se
128. rs defined as views from GeoServer perform the following steps for each of the four views o 5g B o M On the menu on the left select Layers and then Add a new resource In the Add layer from dropdown select the data store created earlier Select Configure new SQL view Add the view name Add the SOL statement Select Guess parameters from SQL and set the default values and regular expression Click Refresh under Attributes and set geometry type SRID and id as layer identifier Click Save On Declared SRS select EPSG 3857 37 Juan Luis Rodas Rivera Technical Report 10 Compute both bounding boxes 11 Click Save In steps 4 to 7 add the following for each view View name cluster_neighboors SQL statement SELECT FROM cluster_neighboors id Yoseq SQL view parameters o id 1 d o seq 0 d Geometry type Polygon 3857 View name photo SQL statement SELECT a b tag_id c name AS tag FROM photo a INNER JOIN photo_tag b ON a id b photo_id INNER JOIN tag c ON b tag_id c id No SQL view parameters Geometry type Point 3857 View name quadrat_count SQL statement SELECT FROM quadrat_count id seq SQL view parameters o id 1 d o seq 0 d Geometry type Polygon 3857 View name study_area_quadrat SQL statement SELECT id AS id ST_Union ST_SnapToGrid geom 0 0001 AS geom FROM study_area_as_hex_quadrat id SQL view parameters o id 1 d Geometry type Polygon
129. s of the GNU General Public License as published the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt oa A require_once dirname __FILE__ vars php Class that represents a cluster of photos calculated by the DBSCAN algorithm copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera class cluster The unique identifier of the cluster var integer Ey private id The list of photos within the main extent of the cluster var photo 7 private Spoints The list of photos that are density reachable from the cluster var photo d private Sdensity_reachable Returns the number of photos in the cluster return integer y function getNumPoints return count Sthis gt points count S this density reachable 112 Juan Luis Rodas Rivera Technical Report Returns the list of photos in the cluster return photo sj function getPoints retu
130. s of the timeframe tf from tf from a seq tf unit tf to tf from tf unit interval 1 second Loop through each quadrat in the study area FOR f1 IN SELECT FROM study area as hex quadrat a id LOOP Return the number photos that are within each quadrat RETURN QUERY SELECT fl id COUNT AS count fl geom FROM photo a INNER JOIN photo tag b ON a id b photo id INNER JOIN filtered photo c ON a id c id WHERE ST Within a geom fl geom AND b tag id tag AND a date taken BETWEEN tf from AND tf to AND a accuracy min acc END END LOOP LANGUAGE plpgsql 57 Juan Luis Rodas Rivera Technical Report Appendix B SOL script to remove the database objects DROPS DROP DROP DROP DROP DROP VIEW VIEW VIEW VIEW VIEW cluster summary photo reduced photo summary study area summary photos on study area DROP DROP DROP DROP DROP FUNCT FUNCT FUNCT FUNCT FUNCT ION cluster neighboors integer integer ION clusters overlap integer integer integer ION quadrat count integer ION reduce photos integer ION study area as hex quadrat integer DROP DROP DROP DROP DROP DROP DROP DROP DROP TABLE TABLE TABLE TABLE TABLE TABLE TABLE TABLE TABLE cluster photo cluster study area filtered photo grabbed photo photo tag data grab tag photo 58 Juan Luis Rodas Rivera Technical Report Appendix C
131. s photo id integer and smallint Fields which use the integer data type have different kinds of restrictions for example a cluster sequential number starts at zero so this field can store values greater or equal to zero the number of time units of a study area cannot be zero since there must be at least one time unit in the timeframe 11 Juan Luis Rodas Rivera Technical Report definition so this field can only store values greater than zero and the minimum number of points needed to define a cluster is two since a cluster cannot be created with just one point so this field can only store values greater than 1 Maximum values for these fields are not restricted and are only capped by the upper limit of the data type 2147483647 Fields which are known to use small integer ranges use the smallint data type These fields include all boolean fields which are restricted to values between 0 and 1 fields which refer to the accuracy of Flickr s photos are restricted to values between 1 and 16 the field which stores the number of the farm for a particular Flickr photo which is restricted to values from 1 to 9 and the field which stores the number of the server used to host a particular Flickr photo which is restricted to values greater than zero Fields which store numbers with decimal values will use the real data type that on PostgreSQL has a precision of 6 decimal digits which is enough when storing values such as distances in met
132. sa_min_accuracy val Send AJAX request to update study area post action ww_study_area php id id description S sa_description val quadrat_size sa_quadrat_size val min_accuracy min_acc eps sa_eps val min pts sa_min_pts val from fsa timeframe from val 00 00 00 time unit sa time unit val time units fsa time units val geom geom upd geom modified When done done function data Update layers addLayers false json Clears the study area drawn by the user AY function clearDrawings Clear feature drawn by user featureOverlay getFeatures clear Add back draw interaction map addInteraction draw Disable store button fbtn store attr disabled true Add a new study area 90 Juan Luis Rodas Rivera Technical Report function store Only store in add mode if mode add Set filter for date var datePattern 2 d d d 0 1 9 1 012 0 1 9 12 0 9 S TOL 7 Check if all fields have been filled if S fsa description val length gt 0 amp amp 4sa time unit val length gt 0 amp amp datePattern test fsa timeframe from val Get coordinates of drawn geometry var coords featureOverlay getFeatures item 0 getGeometry getCoordinates 0 Build WKT var geom POLYGON coords forEach function val geom
133. se edit Sobj new study_area htmlspecialchars _POST id echo mode explore Sobj gt getId lt small gt Study area lt small gt 0bj getDescription lt small gt for tag lt small gt Sobj gt getTag gt getName lt small gt Sobj gt getFrom format Y m d H i s to Sob j gt getTo gt format Y m d H i s small lt small gt Edit lt small gt study area obj gt getId lt small gt for tag lt small gt Sobj gt getTag gt getName break case copy Stag new tag htmlspecialchars _POST id2 Ssa new study area htmlspecialchars POST id Duplicate study area Sobj Ssa gt copy tag Sobj gt store echo lt small gt Copy lt small gt study area sa gt getId lt small gt for tag lt small gt tag gt getName Change mode to edit 67 Juan Luis Rodas Rivera Technical Report Smode edit break p h4 lt div gt lt php Prints the form to add or edit an study area x param integer tag id The unique identifier of the tag param string desc The description of the study area param real quad size The quadrat size of the study area param integer S min acc The minimum accuracy for photos in this study area param real eps The search radius for the DBSCAN algorithm x param integer S min pts The minimum number of points to create a cluster on the
134. se as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt ul require once include vars php Script in charge of getting the clusters which overlap either with another cluster or with another time units copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera Aul Retrieve study area identifier sa htmlspecialchars POST sa Sreturn array Sconn pg_connect CONN_STRING Retrieve cluster which overlap with another cluster if array key exists id POST Retrieve cluster identifier Scluster htmlspecialchars POST id Retrieve area of biggest cluster in this study area Sresultl pg query conn SELECT COALESCE MAX area 0 FROM cluster summary WHERE study area id sa max area pg fetch result resultl1 0 0 if max area gt 0 Retrieve clusters which overlap and their relative siz sql SELECT DISTINCT b seq 10 ST Area b geom
135. ss index css type text css gt lt script sxro js jquery 2 1 1 js type text javascript gt lt script gt script src js bootstrap js type text javascript gt lt script gt lt script src js index js type text javascript gt lt script gt lt head gt lt body data spy scroll data target navbar data offset 80 gt Navigation bar lt div id navbar class navbar navbar default navbar fixed top role navigation gt lt div class container gt div class navbar header gt lt button type button class navbar toggle data toggle collapse data target navbar collapse gt lt span class sr only gt Toggle navigation lt span gt lt span class icon bar gt lt span gt lt span class icon bar gt lt span gt lt span class icon bar gt lt span gt lt button gt 59 Juan Luis Rodas Rivera Technical Report lt a class navbar brand href gt lt span class glyphicon glyphicon globe gt lt span gt Tempo spatial explorer of Flickr tags lt a gt lt div gt lt div class collapse navbar collapse gt lt ul class nav navbar nav gt lt li class active gt lt a href tags gt Current tagse fa e fli lt li gt lt a href fadd tag Add a tag a li lt li gt lt a href study_areas gt Current study areas a li lt li gt lt a href fadd study area Add a study area lt a gt lt li gt lt li gt lt a href manua
136. string Sto Upper boundary of the timeframe return photo F x function getNeighbors Seps Stag S min accuracy geom from Sto 130 Juan Luis Rodas Rivera Technical Report Retrieve all neighbours that meet the search criteria Sreturn array Ssql SELECT a FROM photo_reduced a photo b WHERE ST DWithin a geom b geom eps AND b id Sthis id AND a tag id tag gt getId AND a accuracy gt min accuracy AND a date taken BETWEEN from AND Sto AND ST Within a geom Sgeom Sconn pg connect CONN STRING result pg query conn sql Add them to the returning array while row pg fetch row result array push return new photo Srow 1 row 2 Srow 3 Srow 4 Srow 5 S row 6 S row 7 Srow 8 row 9 Srow 10 row 0 pg close conn return Sreturn 131 Juan Luis Rodas Rivera Technical Report study_area php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by ct he Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details
137. structured as shown on Figure 15 2 http localhost 88 Hu flickr Eg action css img fie iie iie lie Fg fst HE Figure 15 Structure of the root of the web application 31 Juan Luis Rodas Rivera Technical Report The action directory contains all the scripts used by the main web pages when making AJAX requests to insert update delete or retrieve data from the database or perform server side processing like the reduction of photos the calculation of clusters or quadrat count analysis The include directory contains files meant to be used by the main web pages or by the action scripts to perform actions on the database objects Files in this directory include all the classes described on the previous section as well as the application s configuration file vars php which contains global configuration parameters for the application This directory also contains geoPHP a PHP library to perform geometry operations which is used by the study area class to read the geometry column from the database The structure of the files on these folders is shown on Figure 16 EZ include EZ action ata grab php je iai E Tooter php e ww poll tag update php proto h e di a Figure 16 Structure of the include and action folders within the web application geoPHP https github com phayes ge
138. t lt td gt lt td class text right gt lt strong gt total lt strong gt lt td gt lt td colspan 3 gt lt td gt lt td class text right gt lt strong gt td7 lt strong gt lt td gt lt tr gt Observed variance s2 Ssum Stotal Nariance mean ration SVMR s2 Smu Chi square Schi2 Ssum mu tbody 106 Juan Luis Rodas Rivera Technical Report lt table gt lt span class label label primary gt Statistics lt span gt lt table class table gt lt tbody gt SEE php Round values for displaying td8 round Smu 4 Std9 round s2 4 td10 round VMR 4 tdll round Schi2 4 echo lt td class text center var amp micro var td8 lt td gt echo lt td class text center gt lt var gt s lt var gt lt sup gt 2 lt sup gt Std9 td echo lt td class text center var VMR var Std10 lt td gt echo lt td class text center gt lt var gt x lt var gt lt sup gt 2 lt sup gt iStdil jeZtds Ae lt tbody gt lt table gt lt php If there are values on the lookup table for this number of degrees of freedom then display them if array key exists total 1 Slookup lt span class label label primary Critical values lt span gt lt table class table thead tr th class text right gt 0 995 lt th gt lt th class text right 0 975 th th class text
139. t Order CD DVD Hard Disk Acceleration VT x AMD V Nested Paging PAE NX Dissertation 5 Display Video Memory 32 MB Remote Desktop Server Disabled Video Capture Disabled Q Storage Controller SATA SATA Port 0 Dissertation vdi Normal 4 00 GB SATA Port 1 CD DVD VBoxGuestAdditions iso 61 77 MB ja Audio Disabled P Network Intel PRO 1000 MT Desktop NAT Adapter 1 Figure 21 Virtual machine installed on a Windows host To run the tool simply launch the virtual machine selecting Start When Ubuntu finishes loading a prompt will appear To access the tool open a web browser and go to http localhost 88 flickr 43 Juan Luis Rodas Rivera Technical Report This will load the tool s control panel The tool needs access to the internet to download photos from Flickr and the base map on the viewer To access the GeoServer instance on the virtual machine open a web browser and go to http localhost 88 GeoServer To connect to the PostgreSQL instance on the virtual machine use port 5433 on localhost Table 18 lists all the user logins and passwords for the services installed on the virtual machine Table 18 User logins and passwords for services on the virtual machine Service Username Password System user juan flickr PostgreSQL postgres flickr Tomcat application manager admin flickr GeoServer admin GeoServer To shut
140. t for the creation of the tables is included in Appendix A date_added date_taken accuracy usr lat lon farm server secret geom filtered_photo PK FK1 Q N cluster photo PK FK1 cluster id PK FK2 photo id grabbed photo PK FK1 data grab id OS PK FK2 photo id photo tag C PK FK1 photo id PK FK2 tag id study area id seq geom Figure 8 Physical database diagram tag id total started ended latest reduced tag id description quadrat size min accuracy eps min pts time unit time units timeframe from timeframe to calculated updated geom 13 Juan Luis Rodas Rivera Technical Report 6 1 1 Table photo The table photo stores the metadata on the photos downloaded from Flickr It has the structure shown on Table 1 Table 1 Structure of table photo Attribute Data type Allow nulls Description id serial No Unique identifier num bigint No Unique identifier from Flickr date_added timestamp No Date photo was uploaded date taken timestamp No Date photo was taken accuracy smallint No Declared accuracy usr character varying No Owner of the photo 15 lat real No Latitude where photo was taken lon real No Longitude where photo was taken farm smallint No Server farm hosting the photo server smallint No Server hosting the photo secret character 10 No Secret code of the photo geom geometry No Photo location POINT 3857 The id attribute is the primary
141. tag for which photos need to be reduced and outputs the final number of reduced photos 6 3 2 Function cluster neighbours This function finds all clusters that overlap on consecutive time units from a specific time unit The function first loops through all clusters in the specified time unit and for each cluster it loops again from two time units in the past to two time units in the future to find clusters that overlap with it The function receives the identifier of the study area and the time unit on which to look for overlapping clusters on consecutive time units and outputs the list of clusters that overlap indicating for each its relative position in time with the specified time unit The structure of the output generated by the cluster neighbours function is shown on Table 15 Table 15 Structure of the output of function cluster neighbours Attribute Data type Description id integer Identifier of the cluster seq delta integer Relative position in time to specified time unit geom geometry Spatial extent of the cluster area of influence POLYGON 3857 of the core points 24 Juan Luis Rodas Rivera Technical Report 6 3 3 Function clusters overlap This function checks whether clusters on a specified time unit have clusters overlapping in other specified time unit The function receives the identifier of the study area the sequential of the current time unit and the relative position for the time unit on which to look fo
142. th class text right Min pts th th Time unit lt th gt lt th class text right No time units lt th gt lt th class text right Timeframe th th class text right Last update lt th gt lt th class text right Find clusters lt th gt lt th gt Explore lt th gt lt th gt Edit lt th gt lt th gt Delete lt th gt SEES thead lt tbody gt lt php Retrieve list of study areas 63 Juan Luis Rodas Rivera Technical Report Sresult2 pg query conn SELECT FROM study_area_summary ORDER BY name description if pg num rows result2 0 echo tr td class text right ftd td Eunpty td s td td td class text right tgd td class text right td td class text right td td class text right td td td td class text right td td class text right td td class text right td td class text right td td td td td td td tr PHP EOL else Populate list while row pg_fetch_row Sresult2 Check if clusters have been calculated and get number of clusters Sclusters lt button type button class btn btn sm btn default btn block data loading text Please wait onclick calculate_clusters Srow 0 gt lt span class glyphicon glyphicon record gt lt span gt lt button gt if Srow 13 gt 0 Sclusters Srow 13 Print row echo lt tr
143. the availability of the PostGIS extension The PostGIS extension enables support for spatial objects in a PostgreSOL database PostGIS implements the OpenGIS Implementation for Geographic Information Simple Features Access for SOL PostGIS Development Group 2014b PostGIS supports planar geometry and geography data types the former is used on the project to store features such as the locations of the photos study areas quadrats and clusters PostGIS also implements a number of functions to process geometries and calculate spatial relationships and measures many of these functions are used in the project to find spatial relationships and patterns in the data Together these technologies form the spatial processing core of the application Juan Luis Rodas Rivera Technical Report 2 2 GeoServer GeoServer is a geospatial web server written in Java that the implements the open standards set by the Open Geospatial Consortium like Web Feature Service WFS and Web Map Service WMS The GeoServer Project 2014a GeoServer can either run as a standalone service or on top a Java servlet container An Apache Tomcat web application server is used for this purpose GeoServer is an open source project and provides an easy to use frontend to manage the publishing of geospatial data It can connect to a number of vector and raster data sources such as shapefiles and GeoTIFF files and most importantly it supports native connections to the DBMS chos
144. this dateAdded ctl format Y m d H i s Sct2 new DateTime dTaken Sthis gt dateTaken S ct2 gt format Y m d H i s Sthis gt accuracy intval Saccuracy gt 0 intval Saccuracy Sthis gt user string Suser Mercator cannot project coordinates at the poles so reduce tolerance of point switch floatval 1at case 90 0 Sthis gt lat break case 90 0 Sthis gt lat break default Sthis gt lat floatval Slat 85 999995 0p 27299 this gt lon floatval Slon this gt farm intval farm this gt server intval server this gt secret string Ssecret 129 Juan Luis Rodas Rivera Technical Report Store the photo on the database param tag Stag Tag to assign the photo to param data grab dg Data grab used to retrieve the photo A function store tag dg Sconn pg connect CONN STRING Chech if photo already exists Ssel pg select conn photo array num gt S this num if sel 0 If not then store it on the database Ssql INSERT INTO photo num date added date taken accuracy usr lat lon farm server secret geom VALUES Sthis num this gt dateAdded Sthis dateTaken S this accuracy Sthis gt user Sthis lat S this lon Sthis gt farm Sthis server this gt secret S this getGeom pg query conn sql Retrieve the unique identifi
145. this installation method will work on Windows Linux and Mac The accompanying DVD includes the installer for version 4 3 12 93733 of VirtualBox for Windows which was used to create and setup the virtual machine The virtual machine installation requires approximately 3 GB of free disk space Please note that hardware virtualisation technologies VT x AMD V may need to be enabled on the CPU from the BIOS of the host computer to run virtual machines 10 2 2 VirtualBox configuration To deploy the pre configured virtual machine to an installation of VirtualBox perform the following steps 1 Open VirtualBox and on the File menu select Import Appliance 2 On the Appliance to import dialogue select Choose a virtual appliance file to import 3 Browse to the vm folder on the accompanying DVD and select the Dissertation ova file 4 Click Next 42 Juan Luis Rodas Rivera Technical Report 5 Review the details of the virtual machine to be deployed 6 Click Import 7 Accept the software licence VirtualBox will import the virtual machine file and once the process has finished it will be added to the list of installed virtual machines as seen on Figure 21 WY Oracle VM VirtualBox Manager File Machine Help ie up New Settings Start Discard Qe Dissertation S General a Powered Off Name Dissertation Operating System Ubuntu 64 bit System Base Memory 1024MB Processors 2 Boo
146. this program If not see lt http www gnu org licenses gt EP a Scripting for index php i Author Juan Luis Rodas Rivera 2 Copyright c 2014 Juan Luis Rodas Rivera and The University of Edinburgh Updates a tag checking for new photos on Flickr param integer tag The unique identifier of the tag Ay function update tag tag Get cell that called the action var caller pu pu_ tag Get button that called the action var btn caller pu find button Set button to loading state btn button loading Reset progress bar set progress 0 Show progress bar S update_progress parent removeClass hidden Initiate AJAX request to update photos of this tag post action ww_tag php id tag When done done function data Stop asking for update requests clearInterval poll Max progress bar set_progress 100 Reset button state btn button reset Update list of tags with data returned data caller prev text data updated data caller prev prev text data count if data caller next text Yes S data caller next text No 75 Juan Luis Rodas Rivera data caller next next find span text Show data reduction button data caller next next find button removeClass hidden Hide progress bar S update_progress parent addClass hidd
147. tifier of the data grab var integer private Sid The tag for which the data is being downloaded var tag oy private Stag The total number of photos as reported by Flickr var integer Kr private Stotal The number of the page which is being downloaded var integer A private Spage The total number of pages for this data grab 115 Juan Luis Rodas Rivera Technical Report var integer Bie private Spages The time at which the download process started Qvar DateTime private Sstarted The time at which the download process ended var DateTime sy private Sended The total number of photos actually downloaded var integer X private n photos The point of access to Flickr s REST endpoint var Phlickr Api f private Sapi The parameters sent to the flickr photos search method Qvar mixed private Sparms Returns the unique identifier of the data grab return integer S public function getId return Sthis ig Returns the tag for which the data is being downloaded return tag public function getTag return S this tag Returns the total number of photos as reported by Flickr return integer public function getTotal return Sthis gt total Returns the time at which the download process started return string 116 Juan Lu
148. to install Apache and has a Windows host then a good solution is to download a pre compiled and ready to run installation of Apache and PHP for Windows like WAMP Server or XAMPP please note that these packages come with MySQL installed by default so they may need to be configured to connect to PostgreSQL 6 WAMP Server http www wampserver com 7 XAMPP https www apachefriends org 39 Juan Luis Rodas Rivera Technical Report PHP needs to have the following extensions enabled e php curl e php gd2 php pdo pgsql These extensions can be enabled by uncommenting their respective lines in the php ini configuration file The PEAR framework is required to install Phlickr PEAR stands for PHP Extension and Application Repository PEAR can be enabled on Windows hosts by running the go pear bat script on PHP s installation directory After installing PEAR copy the file Phlickr 0 2 8 tgz located on the Phlickr folder on the accompanying DVD to a location on the hard drive Using a command prompt use cd to change folder to the location where the file was copied and run C gt pear install Phlickr 0 2 8 tgz This will install Phlickr As of June 27 2014 the Flickr API went SSL only Martin 2014 This change made calls to the Flickr public API REST endpoint with Phlickr to stop working Code on the project s website has not been upgrade so it needs to be updated manually after installing Phlickr The following steps must be fo
149. ton type button class close id popup closer gt lt span aria hidden true gt amp times lt span gt lt span class sr only gt Close lt span gt lt button gt lt div gt lt div gt lt div gt lt div gt lt div gt lt div gt Footer gt lt php include include footer php echo PHP EOL gt 1 Global variables needed by viewer js script Mode in which the viewer was loaded type string y var mode php echo mode gt Unique identifier of the study area on view type integer f var id lt php echo Smode add Sobj gt getId 1 73 Juan Luis Rodas Rivera Technical Report Unique identifier of the tag of the study area on view Qtype integer var tag_id lt php echo mode add obj gt getTag gt getId obj gt getId gt Geometry of the study area on view type string Sp var geom php echo mode add str replace S20 S 0obj getGeomAsWKT gt Minimum accuracy of the study area on view type integer T var min acc lt php echo mode add Sobj gt getMinAccuracy 1 Boundaries of the timeframe or time units used by the time slider Qtype array var times lt php switch mode Build an array used by the time slider to define the boundaries of each time unit in explore mode case explore for Si
150. tp localhost 8080 GeoServer lt VirtualHost gt Please make sure to add the correct address for the installation used for GeoServer in the previous section After this configuration is done and Apache has been restarted all calls made to localhost GeoServer on the Apache web server will be proxied to localhost 8080 GeoServer Finally the source code for the application can be copied to the www directory of Apache to publish it and access online The source code is under the folder source code on the accompanying DVD The default name of the directory of the application is flickr but it can be changed if needed To access the tool open a web browser and go to 41 Juan Luis Rodas Rivera Technical Report http localhost flickr This will load the tool s control panel The tool needs access to the internet to download photos from Flickr and the base map on the viewer 10 2 Virtual machine install The virtual machine install is more appropriate if the tool is going to be used for browsing or testing The virtual machine contains a minimal installation of Ubuntu Server 14 04 for virtual machines and is completely configured with PostgreSQL PostGIS Tomcat GeoServer Apache and PHP and is ready to run the tool without major configuration from the user 10 2 1 Requirements The only software requirement to run the tool on a virtual machine is the installation of VirtualBox VirtualBox can run on any operating system so
151. tudy area a INNER JOIN tag b ON a tag id b id LEFT OUTER JOIN SELECT study area id COUNT as count FROM cluster GROUP BY study area id c ON a id c study area id View that selects the identifiers of the photos located within each study area CREATE OR REPLACE VIEW photos on study area AS SELECT a id AS study area id b tag id d FROM study area a INNER JOIN photo tag b ON a tag id b tag id INNER JOIN filtered photo c ON b photo id c id INNER JOIN photo d ON c id d id WHERE d accuracy gt a min accuracy AND d date taken BETWEEN a timeframe from AND a timeframe to AND ST Within d geom a geom FUNCTIONS Selects the photos to be reduced for a particular tag CREATE OR REPLACE FUNCTION reduce photos a tag id integer RETURNS integer AS DECLARE fl record Outer loop every unique pair of user and date taken f2 record Inner loop every photo by the same user on the same day a x double precision Stores cumulative x coordinates a y double precision Stores cumulative y coordinates i integer 0 Counts the number of photos j integer Stores the number of photos by a same user on the same day to calculate the averag BEGIN Delete existing filtered photos DELETE FROM filtered photo WHERE id IN SELECT a id FROM photo a INNER JOIN photo tag b ON a id b photo id WHERE b tag id a tag id Delete existing clusters for this tag 52 Juan Luis Rodas R
152. ue identifier of the study area return integer public function getId return this id 134 Juan Luis Rodas Rivera Technical Report Returns the tag asociated to the study area return tag f public function getTag return S this tag Returns the textual description of the study area return string public function getDescription return this gt description Sets the textual description of the study area x param string description The new textual description public function setDescription description if Sthis gt description description Sthis gt description description Sthis upd description true Returns the quadrat size used in the study area return real k public function getQuadratSize return this quadrat size Sets the quadrat size used in the study area param real quadrat size The new quadrat size kf public function setQuadratSize quadrat size if Sthis quadrat size quadrat size Sthis quadrat size quadrat size S this upd quadrat size true Returns the minimal accuracy for photos in the study area return integer x public function getMinAccuracy return Sthis gt min_accuracy Sets the minimal accuracy for photos in the study area param integer min accuracy The new minimal accuracy public function setMinAccuracy min accuracy if St
153. uld have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt ul require once include vars php Script in charge of performing data reduction for a set of photos copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera tu Retrieve the identifier of the tag for which photos will be reduced tag id htmlspecialchars _POST tag Call the photo reduction function in the database Sconn pg_connect CONN_STRING result pg query conn SELECT reduce_photos Stag_id Retrieve the reduced number of photos Snum pg fetch result result 0 0 Return the reduced number of photos in JSON format header Content Type application json echo json encode array caller gt rd_ tag id num gt num JSON PRETTY PRINT die 108 Juan Luis Rodas Rivera Technical Report ww_study_area php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by ct he Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FI
154. ver data store 36 Figure 19 Example of the list of layers iri Geoberver see etes 37 Figure 20 Example of how to set up a SQL view layer sss 39 Figure 21 Virtual machine installed on a Windows host sse 43 Juan Luis Rodas Rivera Technical Report List of Tables Table 1 Structure Gt t ble OE spss tose e arte toto eeu sedie orcas aha EA deer 14 Table 2 Struct r Of table TAg ete eoa urine aioe tado p cinta ee a tat ale 15 Table o Structure Of table data ergab uae e tr tee bee aes Re tech tube Nt daa is 15 Table 4 Structuteof table photo fae sci sais e taaa Senin Urea ERROR SEPARAR GE 16 Table 5 Structure of table grabbed photons od oe ee toticodeeer taboo Renecsie 17 Table 6 Structure of table filtered_photo iei terti t tetra leslie eterni 17 Table 7 Structure of table study_area o asset ed eret dali rn o Opere nale 18 Table 8 Stricture of table CHIefer iso ci ie Repo ditta quebrada ae ceeded 19 Table 9 Structure of table cluster pHOTO si aac OE i Rec Retr a Da tpe beeen 20 Table 10 Structure Of view Cluster SuUmiQlIad d a cook hti coat inate 20 Table 11 Structure of view photo Teduced uaae ettet ettet tria ania feeit ee tetigi 21 Table 12 Structure Of view photo_summary as ecelesie parte e dea 22 Table 13 Structure of view study aren SHmmatyissis tes quta tested d eni 22 Table 14 Structure of View photos O11 study ATOM uisi ote etre tte ere ee ebiten 23 Table 15 Structure of the output
155. vigator td year last border right none navigator td background color ghostwhite font size smaller vertical align bottom text align center img bar img overlap display block margin left auto margin right auto map height 560px width 100 ol popup display none position absolute background color white moz box shadow 0 lpx 4px rgba 0 0 0 0 2 webkit filter drop shadow 0 lpx 4px rgba 0 0 0 0 2 filter drop shadow 0 lpx 4px rgba 0 0 0 0 2 padding 15px border radius 10px border lpx solid cccccc bottom 12px left 50px ol popup after ol popup before top 100 border solid transparent content T T height 0 97 Juan Luis Rodas Rivera width 0 position absolute pointer events none ol popup after border top color white border width 10px left 48px margin left 10px ol popup before border top color cccccc border width 11px left 48px margin left 1llpx Technical Report 98 Juan Luis Rodas Rivera Technical Report Appendix F PHP code for the files in the action folder ww_clusters php lt php This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it wil
156. wes ciere 47 Juan Luis Rodas Rivera Technical Report List of Figures Figure 1 Arehiteckire used by the too nrs tet orto eei m qoc 5 Figure 2 Photo entity and its attributes soak ess care e onines redi anata tals 7 Figure 3 Tag entity and its attribute ei oe E de See o peces tee e s dieta dues 8 Figure 4 Data grab entity and its attributes oue dd aaa 8 Figure 5 Study area entity arid its attributes eere ii ete eerte ue it eerta deter e 9 Figure 6 Cluster entity and its attributes 5 eneseteer eterne tette reden ted i 9 Figure 7 Entity relationship diagram for the application sss 11 Figure 8 Physical database diagratm u oci tee Rp dita uota desi Feo darian 13 Figure 9 Class diagram for photo class Acc eg te tec oC B eee 27 Figure 10 Class diagram for tag Glass cete taabiansactetststastbeeast buda 27 Figure 11 Class diagram for data grab class sheets 28 Figure 12 Class diagram for clustemel3855 us cepi Cen aede etes dig suia epa t erint 28 Figure 13 Class diagram for dbscan algorithm class sss 28 Figure 14 Class diagram for study area class eee ete tte un 29 Figure 15 Structure of the root of the web application ios etre 31 Figure 16 Structure of the include and action folders within the web application 32 Figure 17 Structure of the js and css folders within the web application 33 Figure 18 Configuration example for a GeoSer
157. wnloaded in the form of two attributes the date the photo was taken and the date the photo was downloaded Spatial data will include the latitude the longitude and the accuracy of the locational data on the photo Finally three other attributes are necessary to build the URL used to show previews of the photo these are the codes for the farm the server and the secret which is a unique string for each photo The photo entity and its attributes are shown on Figure 2 J Photo Server Date added A Location Accuracy Figure 2 Photo entity and its attributes li Owner Identifier Date taken Juan Luis Rodas Rivera Technical Report 5 1 2 Tag entity This entity represents a tag defined as a keyword used to identify a photo The tag entity is very simple and constitutes only the name of the keyword describing the tag This is shown on Figure 3 Tag v Name Figure 3 Tag entity and its attribute 5 13 Data grab entity This entity represents the act of downloading a set of photos from Flickr and stores attributes that can act as a log of the download process These attributes include temporal timestamps of the moment the download process was started and the moment the download process was finished as well as the total number of photos available indicated by the Flickr API Two boolean flags are used to denote a row which is marked as the latest dow
158. ww gnu org licenses gt xy require once dirname __FILE__ vars php require once dirname FILE photo php require once dirname FILE cluster php Implementation of the DBSCAN clustering algorithm copyright c 2014 Juan Luis Rodas Rivera and the University of Edinburgh author Juan Luis Rodas Rivera Ef class dbscan_algorithm Tag for which the clusters are being calculated var tag 4 private Stag Minimum accuracy of the points on the calculation var integer private min accuracy WKT geometry of the study area var string private Sgeom Search distance var real private Seps Lower boundary of the timeframe var string 120 Juan Luis Rodas Rivera Technical Report uii private from Upper boundary of the timeframe var string E private to Minimum number of points to define a cluster var integer y private min pts List of photos that fall within the search criteria var photo private Spoints List of clusters found Qvar cluster private clusters List with that contains data on which photos have been visited var integer yf private S visited Returns the search distance return real public function getEps return Sthis gt eps Returns the minimum number of points to define a cluster
159. y new ol Overlay element container Map element Qtype ol Map var map new ol Map target map layers baseLayer overlays overlay view view Scale line type ol control ScaleLine a var scale line new ol control ScaleLine Set the scale line on the map param ol Map param Scale line setMap map Fires interactions when the map is clicked param type pixel param type coordinate var mapClicked function pixel coordinate var action none Check for action and feature clicked var feature map forEachFeatureAtPixel pixel function feature layer if layer photoLayer action display photo return feature else if layer clusterLayer action show overlaping clusters Only return cluster if exists in current time unit if feature get seq delta 0 return feature 92 Juan Luis Rodas Rivera Technical Report If a feature has been clicked if feature If clicked on a photo if action display photo Set photo preview overlay on the coordinates clicked overlay setPosition coordinate Set title of the photo overlay Flickr id and user popup content prev first h3 find span text feature get num S popup content prev first h3 find small text feature get usr Load photo from Flickr content i
160. y id gt this ag Sthis gt name result 0 name else Convert name to lower case Sthis gt name strtolower name Retrieve unique identifier from database result pg select conn tag array name gt this gt name if result 0 If the tag does not exist in the database insert it pg insert conn tag array name gt Sthis name Sthis id pg fetch result pg query conn SELECT currval tag id seg Ug D else Assign the unique identifier to the tag this id rfesult S I id pg close conn 145 Juan Luis Rodas Rivera Technical Report vars php lt php Jk This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details TI Xo xo x You should have received a copy of the GNU General Public License along with this program If not see http www gnu org licenses File which contains configuration parameters for the application copyright c 2014 Juan Luis Rodas

Download Pdf Manuals

image

Related Search

RodasRivera2014_PartII

Related Contents

Manuel d`utilisateur du canal de transfert MQ-link    USER`S MANUAL N2-MISTRAL-0 / 25 L/min    Diapositive 1 - Charlebois Alimentation  Tristar Sapcentrifuge  Picture Style Editor  RU - Autohaus Habinghorst Shop  INSTRUCTION MANUAL    

Copyright © All rights reserved.
Failed to retrieve file