Nasrul Hazim Bin Mohamad

Training: Web Mobile Application Development (Basic / Intermediate) – INTIM – August 2015

Aug
16

Training: Web Mobile Application Development (Basic / Intermediate)

Location: INTAN Kampus Wilayah Timur (INTIM), Kemaman, Terengganu

Date: 17th – 20th August 2015

Slide: http://bit.ly/training-web-mobile-application-development

Training Materials:

  1. Web Mobile Application Starter Kit – https://bit.ly/training-mobile-app-starter-kit
  2. Basic Android Configuration – https://bit.ly/training-mobile-app-android-config
  3. API Template – https://bit.ly/training-api-template

Important Articles:

  1. HTTP Methods for Restful Services – http://bit.ly/htpp-nethods-for-restful-services
  2. Android Configuration – http://bit.ly/android-config-xml
  3. Chrome Device Mode – http://bit.ly/chrome-device-mode

 

GeoServer – GetFeatureInfo Template Data Model (structure)

Mar
21

Extend from this GeoServer – Custom Get Feature Info Display

Knowledge requirement – Freemaker

The standard template files is header.tpl, content.tpl, footer.tpl.

header.tpl usually where JavaScript, CSS, meta tag, title placed here.

footer.tpl where you put your HTML page footer, Copyright, etc.

content.tpl where we going to iterate through all the features to display interactive UI. But here, I’m going to explain the structure of all available variables.

/**
features (array of Feature)
	[0]
		- fid
		- typeName
		- attributes
			-> name
			-> type
			-> isGeometry
			-> value
		- type
			-> name
			-> title
			-> abstract
			-> description
			-> keywords
			-> metadataLinks
			-> SRS
			-> nativeCRS
	[n]
	
type (object of Feature Map)
	- name
	- attributes
		-> name
		-> type
		-> isGeometry
**/

Accessing the variables as following:

<!-- Accessing Feature Type Name -->
<h3>${type.name}</h3>

<!-- Accessing Features at index 0 and assign to a variable named feature -->
<#assign feature = features[0]>

<!-- Get feature's attributes values and assign to a variable named attrs -->
<#assign attrs = feature.attributes>

<!-- Display an attribute -->
<p>${attr.someFieldName.value}</p>

The result may display as below:

This is type name

some field name value

Reference: http://docs.geoserver.org/2.1.4/user/tutorials/freemarker.html

Data Structure – Creating Tree Data Structure

Jan
21

As per title, this post will give an example how to create a tree data structure using recursive function.

The data structure will be like below illustration:

/A
–/A-1
—-/A-1-a
—-/A-1-b
/B
/C
–/C-1
—-/C-1-c

Below is an implementation based on this post – a folder tree created based on given directory using recursive function.

Data Structure - Tree

Data Structure – Tree

Here are the code:

public function generateTree($value) {
	$list = array();
	if ($handle = opendir($value)) 
	{
		while (false !== ($entry = readdir($handle))) 
		{
			if ($entry != "." && $entry != "..") 
			{	
				if(is_dir($value . '/' .$entry))
				{
					$list[] = array( 
						'text' => $entry, 
						'children' => generateTree($value . '/' .$entry)
					);
				}
				else
				{
					$list[] = pathinfo($entry);
				}
			}
		}
		closedir($handle);
	}
	return $list;
}

Just set the following:

$list = generateTree('path/');

You should get something similar to below when you print_r($list);.

[
	{
		'text':'A',
		'children':
		[
			{
				'text':'A-1',
				'children':
				[
					{
						'text':'A-1-a'
					},
					{
						'text':'A-1-b'
					}
				]
			}
		]
	},
	{
		'text':'B'
	}
	{
		'text':'C',
		'children':
		[
			'text':'C-1',
			'children':
			[
				{
					'text':'C-1-c'
				}
			]
		]
	}
]