0% found this document useful (0 votes)
103 views23 pages

Dynamic Web Gis: Jumadi, PHD

Static websites have web pages stored on the server in HTML format, while dynamic websites have pages that change automatically based on criteria, usually driven by server-side scripts like SQL, PHP, and ASP.NET. The basic disadvantage of static sites is that they require web professionals for any changes, while dynamic sites allow for more customization and easy updating but have higher initial costs to set up.

Uploaded by

AZAM SAPUTRA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views23 pages

Dynamic Web Gis: Jumadi, PHD

Static websites have web pages stored on the server in HTML format, while dynamic websites have pages that change automatically based on criteria, usually driven by server-side scripts like SQL, PHP, and ASP.NET. The basic disadvantage of static sites is that they require web professionals for any changes, while dynamic sites allow for more customization and easy updating but have higher initial costs to set up.

Uploaded by

AZAM SAPUTRA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Dynamic Web GIS

Jumadi, PhD
Static website: is one that has web pages stored on the server in the format that is
sent to a client web browser. It is primarily coded in Hypertext Markup Language
(HTML).

Dynamic Website: is one that changes or customizes content automatically and/or


frequently based on certain criteria. The page composition is usually data-driven and
collates information each time a page is requested. It is primarily coded using server
scripting such as SQL, ASP, PHP, ASP.NET and so on.

2
Static
Advantages
 Quick and easy to put together, even by someone who doesn't have
much experience.
 Ideal for demonstrating how a site will look.
 Cache friendly, one copy can be shown to many people.

Disadvantages
 Difficult to maintain when a site gets large.
 Difficult to keep consistent and up to date.
 Offers little visitor personalization (all would have to be client side).
3
Static - Disadvantage
Disadvantages
 The basic disadvantage of static web sites is the web
pages are developed at the time of constructing the site.
As such, all static website owners have to be abjectly
dependent on Web professionals whenever any changes
become necessary. Though the initial cost of setting up a
static Website may not be costly, its long term
maintenance will be expensive – more so, if the site owner
wishes to effect changes at regular intervals.

4
What we have done
What we will do (dynamic)
Dynamics GeoJson
How to generate GeoJson
Remember the rules
GeoJson
Stucture
Feature

FeatureCollection
Geometry Properties

Feature

Geometry Properties
Format
Format
Format
Useful functions for the converter
• MySQL function
• ST_AsGeoJSON(g)
• PHP functions
• json_decode($geomobject)
• json_encode($geomobject)
ST_AsGeoJSON(g)
• Converting GEOMETRY field into
GeoJson format.
• Example: select
OGR_FID,desa,ST_asGeoJson(SHA
PE) from kartasura
{"type": "Polygon", "coordinates":
[[[110.757526676, -7.56198921399994],
[110.76217, -7.56348], [110.76247, -7.56358],
[110.76281, -7.56369], [110.76303, -7.56376],
[110.76324, -7.56381], [110.76355, -7.5639],
[110.76497, -7.56435], [110.7651, -7.56439],
[110.76555, -7.56452], [110.76573, -7.56457],
[110.767579144, -7.56516953299996],
[110.768006511, -7.56532486399993],
[110.768407999, -7.56542848], [110.768692931,
json_decode()
• Conver Json into object in php.

$json={"type": "Polygon", "coordinates":


[[[110.757526676, -7.56198921399994],
[110.76217, -7.56348], [110.76217, -7.56348]]]}

$obj =json_decode($json)

$obj->type= "Polygon";
$obj-> coordinates=[[[110.757526676,
-7.56198921399994], [110.76217, -7.56348],
[110.76217, -7.56348]]]
json_encode()
• Converting PHP object into JSON.
$obj->type= "Polygon";
$obj-> coordinates=[[[110.757526676,
-7.56198921399994], [110.76217, -7.56348],
[110.76217, -7.56348]]]

$obj =json_encode($json)

$json={"type": "Polygon", "coordinates":


[[[110.757526676, -7.56198921399994],
[110.76217, -7.56348], [110.76217, -7.56348]]]}
Conversion steps
• Connect to MySQL database
• Spatial query: convert GEOMETRY to GeoJSON + the
attributes
• Decoding and restructuring:
• Read the query results,
• convert the attributes into object array,
• decode the GeoJson,
• put attributes and geometry as array following GeoJson
Feature structure,
• Put the object array into FeatureCollection (array).
• Encoding: encode the restructured data into Json
The converts script: example
<?php
//Connect to MySQL database
$connection = mysqli_connect("localhost", "root", "", "data_sig");

//Spatial query: convert GEOMETRY to GeoJSON + the attributes


$sql="select OGR_FID,desa,ST_asGeoJson(SHAPE) geom from kartasura";
$result = mysqli_query($connection,$sql);

//Decoding and restructuring:


$i=0; $json = array();

//Read the query results,


while($row = mysqli_fetch_array($result)){

//convert the attributes into object array


$attributes = array("OGR_FID"=>$row['OGR_FID'],"NAME"=>$row['desa']);

//decode the GeoJson


$geom = json_decode($row['geom'], true);

//put the attributes and geometry as array following GeoJson Feature structure,
$data = array("type"=>"Feature", "id"=>$row['OGR_FID'], "properties"=> $attributes, "geometry"=>$geom);

$json[$i]=$data; $i++;

//put all together in Geojson FeatureCollection formatted structure array


$jsons = array("type"=>"FeatureCollection","features"=>$json);

//Encoding: encode the restructured data into Json


echo json_encode($jsons);

//Close connection to MySQL database


mysqli_close($connection); ?>
Converting your MySQL data
Loading your data and visualize in
Leaflet
var URL = "http://localhost/latihan6/gjson.php";
var jsonmap = L.geoJson.ajax(URL,{onEachFeature:
onEachFeatureFunction }).addTo(mymap);
Assignment 8
• Create your own
dynamic GeoJson.
• Visualise in Leaflet.
• Create and visualise also
the GeoJson for table
toko (remember tugas
5).
Discussions?

You might also like