Pemanggilan Class Sistem Informasi Geografis Penentuan Lokasi Hydrant Berbasis Web Dengan Metode Simple Additive Weighting di Wilayah Kota Medan

Listing program

1. Pemanggilan Class

?php Quick, clean clear defined __GISSAW__ or die Get out of here ; require_once includesconfig.php ; require_once includesclass_config.php ; require_once includesfunctions.php ; require_once includesclass_template.php ; require_once includesclass_gissaw.php ; require_once includesclass_html.php ; required = includes; if is_dir required { dir = opendir required ; while file = readdir dir == false { if file = . file = .. { require_once required . . file ; } } } ? Config Program untuk menampilkan tulisan pada halaman utama home ?php Quick, clean clear defined __GISSAW__ or die Get out of here ; App configuration define WEB_AUTHOR, Herna Junita Pakpahan081201021 ; define WEB_TITLE, Sistem Informasi Geografis Penentuan Lokasi Hydrant Dengan Metode Simple Additive Weighting Berbasis Web di Wilayah Kota Medan ; define WEB_APP_TITLE, Sistem Informasi Geografis Penentuan Lokasi Hydrant Dengan Metode Simple Additive Weighting Berbasis Web di Wilayah Kota Medan ; define WEB_COPYRIGHT, Program Studi S1 Ilmu Komputer brFakultas Ilmu Komputer dan Tehnik InformasibrUniversitas Sumatera UtarabrMedan 20112012 ; Set manually Universitas Sumatera Utara define BASE_URL, http:localhostgissaw ; ? Class config ?php Quick, clean clear defined __GISSAW__ or die Get out of here ; It might be more complext as you want class Config { var web_author; var web_title; var web_app_title; var web_copyright; var alternative = array 0 = Kec. Medan Deli Asub1sub, 1 = Kec. Medan Sunggal Asub2sub, 2 = Kec. Medan Selayang Asub3sub ; Add more alternative here public function __construct { this-web_author = WEB_AUTHOR; this-web_title = WEB_TITLE; this-web_app_title = WEB_APP_TITLE; this-web_copyright = WEB_COPYRIGHT; } public function web_author author= { if author = { return author; } else { return this-web_author; Print the default title } } public function web_title title = { if title = { return title; } else { Universitas Sumatera Utara return this-web_title; Print the default title } } public function web_app_title app_title = { if app_title = { return app_title; } else { return this-web_app_title; Print the default title } } public function web_copyright copyright= { if copyright = { echo copyright; } else { echo this-web_copyright; Print the default title } } } Turn on the configuration as default config = new Config; ? Class_Functions ?php Quick, clean clear defined __GISSAW__ or die Get out of here ; function base_url { return BASE_URL; } function redirect url { headerLocation: . url ; } ? Class template Universitas Sumatera Utara ?php Quick, clean clear defined __GISSAW__ or die Get out of here ; class Template { var page_title; var temp_path; var copyright; var page; var config; var winner; public function __construct template_path { this-temp_path = template_path; this-config = new Config; } public function set_header header { ? img src=?php echo this-temp_path . images . header; ? width=100 height=100 ?php } public function set_logo logo { ? img src=?php echo base_url . images . logo; ? title=Universitas Sumatera Utara width=35 align=left ?php } public function set_title title { this-page_title = ucwords strtolower title ; } public function html_header images = array { ? DOCTYPE html PUBLIC -W3CDTD XHTML 1.0 TransitionalEN http:www.w3.orgTRxhtml1DTDxhtml1- transitional.dtd html xmlns=http:www.w3.org1999xhtml head meta http-equiv=Content-Type content=texthtml; charset=iso-8859-1 Universitas Sumatera Utara link rel=icon type=imagex-icon href=?php echo base_url; ?imagesfavicon.png link rel=stylesheet type=textcss href=?php echo this-temp_path; ?style.css script language=javascript type=textjavascript src=?php echo this-temp_path; ?jscript.jsscript meta name=author content=?php echo this-config- web_author; ? title?php echo this-page_title; ?title head ?php } public function set_page page { this-page = page; } public function load_page page = { if page = { if file_exists themedefault . page . .php { require_once themedefault . page . .php ; } else { echo No page . \n; } } else { if file_exists themedefault . this- page . .php { require_once themedefault . this-page . .php ; } else { echo No page . \n; } } } public function html_footer { ? body body Universitas Sumatera Utara html ?php } public function run { this-html_header; require_once themedefaultindex.php ; this-html_footer; } } ? Class gissaw ?php Quick, clean clear defined __GISSAW__ or die Get out of here ; class Gissaw { The weight of criteria var criteria = array; Hold the matrix Rij alternative x criteria. But, it element is the number of Alternative. Recall that var alternative = array; N x N matrix alternative x criteria var elements; -- Required OR depreciated ? Rij is the bridge to build normalized matrix var rij = array; Normalized matrix var r_matrix = array; hold the most weight of element from the normalized matrix var max_weight = array; Preferensi of alternative V1 var preferensi = array; Preferensi label var preflabel = array; public function find_max alt = array { max = 0; foreach alt as v Universitas Sumatera Utara { if v max max = v; } return max; } public function who_max alt = array, val { foreach alt as k = v { if val == v { return k; break; } } } Once we have Rij matrix from the user, its time to normalized it public function normalize_matrix { First of all we need to restructure the matrix into Rij so that we can get closer to the way of normalization matrix for i = 1; i = count this-criteria ; i++ 5 times { for j = 1; j = count this- alternative ; j++ 3 times { array_push this-rij, this- alternative[j][i] ; } } Now keep the maximum value of each column matrix Rij c = 1; max = 0; for i = 0; i count this-rij; i++ { if this-rij[i] max { max = this-rij[i]; } c++; if c count this-alternative { Universitas Sumatera Utara array_push this-max_weight, max; c = 1; max = 0; } } Build normalized matrix c = 0; d = 0; for i = 1; i = count this-criteria; i++ 5 times { for j = 1; j = count this- alternative ; j++ 3 times { this-r_matrix[j][i] = round this-rij[c] this-max_weight[d], 3 ; c++; } d++; } Now that, we have normalized matrix. Yay } public function execute { config = new Config; session_start; this-normalize_matrix; Keep the number elements of N x N matrix, so that we can loop it in another page due to unsupported session for multidemensial array I doubt it ;- _SESSION[row] = count this-alternative ; _SESSION[column] = count this-criteria ; No more than an interface weight = 0; index = 0; str = ; foreach this-r_matrix as key = val { foreach val as key1 = val1 { weight = val1 this- criteria[index] + weight; operator = index == count this- criteria - 1 ? = : + ; str .= . val1 . . this- criteria[index] . . operator; Universitas Sumatera Utara _SESSION[i . key][j . key1] = val1; index++; } array_push this-preferensi, weight ; Hold the total result array_push this-preflabel, str ; Hold its process index = 0; weight = 0; str = ; } foreach this-preferensi as key = val { _SESSION[V . key] = val; return V0, V1, V2 for A1, A2, A3 } foreach this-preflabel as key = val { _SESSION[L . key] = val; return L0, L1, L2 for A1, A2, A3 } Write the winner to the buffer winner_index = this-who_max this- preferensi, this-find_max this-preferensi ; _SESSION[winner_label] = config- alternative[winner_index]; _SESSION[winner_value] = this-find_max this-preferensi ; } } ? Class html ?php Quick, clean clear defined __GISSAW__ or die Get out of here ; class HTML { public function radio name, yes, no, current_value = { if current_value == 0 { ? input type=radio value=0 name=?php echo name; ? checked=checked ?php echo no; ? Universitas Sumatera Utara input type=radio value=1 name=?php echo name; ? ?php echo yes; ? ?php } else { ? input type=radio value=0 name=?php echo name; ? ?php echo no; ? input type=radio value=1 name=?php echo name; ? checked=checked ?php echo yes; ? ?php } } public function button type, caption, base_url = { if type == cancel { return input type=button value= . caption . onClick=history.back class=buttonnbsp;nbsp;; } else { if base_url = { return input type= . type . value= . caption . onClick=location.href=\base_url\ class=buttonnbsp;nbsp;; } else { return input type= . type . value= . caption . class=buttonnbsp;nbsp;; } } } public function select value = array, name, cur_value { ? select name=?php echo name; ? class=selectedfield option value=-Noneoption ?php foreach value as key = val { ? ?php if key == cur_value { ? option value=?php echo key; ? selected=selected?php echo val; ?option ?php } else { ? option value=?php echo key; ??php echo val; ?option ?php } ? ?php } ? select ?php Universitas Sumatera Utara } public function combo_box name { ? select name=?php echo name; ? class=selectedfield option value=0.000.00option option value=0.200.20option option value=0.400.40option option value=0.600.60option option value=0.800.80option option value=1.001.00option select ?php } } ?

2. Template