Example #1
0
    print $result;
    break;

  case 'getlayerextent':
    require_once("mapdata.php");
    $table=$_REQUEST['layer_name'];
    $fids='';
    if (isset($_REQUEST['fids'])) {
      $fids=$_REQUEST['fids'];
    }
    $layertype=getLayerType($table);
    if ($fids != '') {
      print getLayerExtent($table, $layertype, $fids);
    }
    else {
      print getLayerExtent($table, $layertype);
    }

    break;

  case 'getfeaturecount':
    require_once("mapdata.php");
    $table=$_REQUEST['layer_name'];
    $result=getFeatureCountForLayer($table);
    print $result;
    break;

  case 'getDODCount':
    require_once("mapdata.php");
    $table=$_REQUEST['layer_name'];
    $BBOX=$_REQUEST['BBOX'];
Example #2
0
function get_layer_details($layer_tablename, $fids) {
  $query='select layer_type,layer_id,color_by,size_by,participation_type, nid, p_nid,access,layer_name,max_scale, is_timebased from "Meta_Layer" where layer_tablename= \'%s\'';
  $result=db_query($query, $layer_tablename);
  while($row=db_fetch_object($result)) {
    $layertype;
    $arr_str=array();
    $arr_str['layer_tablename']=$layer_tablename;
    switch($row->layer_type) {
      case "POINT":
      case "MULTIPOINT":
        $layertype='POINT';
        break;

      case "MULTIPOLYGON":
      case "POLYGON":
        $layertype='POLYGON';
        break;

      case "MULTILINESTRING":
      case "LINE":
        $layertype='LINE';
        break;

      default:
        $layertype=$row->layer_type;
        break;
    }
    // switch

    $arr_str['layer_type']=$layertype;
    $arr_str['layer_id']=$row->layer_id;

    if($layertype == 'POLYGON' || $layertype == 'LINE') {
      if($row->color_by == '') {
        $arr_str['variation_by_column']='(No color-by column specified)';
      }
      else {
        $col_info=getDBColDesc($layer_tablename, $row->color_by);
        $color_by=str_replace("'", "", $row->color_by);
        $arr_str['variation_by_column']='(' . ($col_info[$color_by] == "" ? $color_by : $col_info[$color_by]) . ')';
      }
    }
    elseif($layertype == 'POINT') {
      if($row->size_by == '') {
        $arr_str['variation_by_column']='(No size-by column specified)';
      }
      else {
        $col_info=getDBColDesc($layer_tablename, $row->size_by);
        $size_by=str_replace("'", "", $row->size_by);
        $arr_str['variation_by_column']='(' . ($col_info[$size_by] == "" ? $size_by : $col_info[$size_by]) . ')';
      }
    }

    $hasAddPerm=(userHasAddFeaturePerm($layer_tablename) ? 1 : 0);

    $arr_str['participation_type']=$row->participation_type;
    $arr_str['nid']=$row->nid;
    $arr_str['p_nid']=$row->p_nid;
    $arr_str['addFeaturePerm']=$hasAddPerm;
    $arr_str['projection']=getLayerProjection($layer_tablename);
    $arr_str['access']=$row->access;
    $arr_str['layer_name']=$row->layer_name;

    $max_zoom=$row->max_scale;
    if($max_zoom == NULL || $max_zoom == "" || $max_zoom < 5) {
      $max_zoom=19;
    }
    $arr_str['max_zoom']=$max_zoom;

    /*
     * feature count cant be determined for raster layer,so value one
     * is assigned so that the map will be zoomed to the layer extent
     * when the layer is added.
    */

    if('RASTER' == $layertype)
      $f_count=1;
    else
      $f_count=getFeatureCount($layer_tablename);
    $arr_str['feature_count']=$f_count;

    $extent='';
    if($fids != NULL) {
      $extent=getLayerExtent($layer_tablename, $layertype, $fids);
    }
    else {
      $extent=getLayerExtent($layer_tablename, $layertype);
    }
    $arr_str['extent']=$extent;

    $arr_str['is_timebased']=$row->is_timebased;
  }
  print json_encode($arr_str);
}
Example #3
0
function treeViewEntryJSON($layer_tablename, $layer_name, $participation_type, $p_nid, $access, $fids = null, $feature_count = null)
{
	// temporary json variable whose value is returned to the calling function
	$json = array();

	$layersChecked = $GLOBALS['layersChecked'];

	if ($fids == null) {
		$chkBxName = "categories";
	} else { // It is either search or validate tab
		$chkBxName = $fids;
	}

	$checked = "";
	$display_extent = "none";

	if (in_array($layer_tablename, $layersChecked))
	{
		$checked = "checked";
		$display_extent = "inline";
	}

	$json['layer_name'] = $layer_name;
	$json['layer_tablename'] = $layer_tablename;
	$json['chkBxName'] = $chkBxName;
	$json['checked'] = $checked;
	$json['display_extent'] = $display_extent;
	$json['feature_count'] = $feature_count;
	$json['p_nid'] = $p_nid;

	$imgUrl = base_path() . path_to_theme().'/images/icons/information.png';
	$json['info_imgUrl'] = $imgUrl;


	$imgUrl = base_path().path_to_theme().'/images/icons/participate.png';
	if ($participation_type > 0) {
		$json['prtcptn_imgUrl'] = $imgUrl;
	}

	if($fids == null)
	{
		$imgUrl = base_path().path_to_theme().'/images/icons/download-layertree.png';
		if($access) {
			$json['downl_imgUrl'] = $imgUrl;
		}
	}
	if($fids == null){
		$imgUrl = base_path().path_to_theme().'/images/icons/zoom-to-extent.png';
		$json['layer_extent'] = getLayerExtent($layer_tablename, $fids);
		$json['zoomtoext_imgUrl'] = $imgUrl;
	}

	return $json;
}
Example #4
0
function formLayersListXML($xmlDoc, &$rootNode, $layer_tablename, $layer_name, $access, $p_nid, $participation_type) {
  $imgPath = base_path() . path_to_theme().'/images/icons/';
  $layertype = '';

  /* get the layer type */
  $query = 'select layer_type from "Meta_Layer" where layer_tablename= \'%s\'';
  $result = db_query($query, $layer_tablename);
  while($row = db_fetch_object($result)) {
    $layertype = $row->layer_type;
  }

  $attribs = array();
  $attribs['layer_tablename'] = $layer_tablename;
  $attribs['layer_name'] = $layer_name;
  $attribs['icon'] = getLayerIconUrl($layer_tablename);
  $layersChecked = explode(":", $_COOKIE['layersChecked']);
  if (in_array($layer_tablename, $layersChecked)) {
    $attribs['checked'] = 1;
  } else {
    $attribs['checked'] = 0;
  }
  $lyrNode = addXMLChildNode($xmlDoc, $rootNode, "layer", null, $attribs);
  $toolsNode = addXMLChildNode($xmlDoc, $lyrNode, "tools");

  addTool($xmlDoc, $toolsNode, 'information', $imgPath .'information.png', $layer_name . ' Information', 'getLayerMetadata', array($layer_tablename));

  if ($participation_type > 0) {
    addTool($xmlDoc, $toolsNode, 'participate', $imgPath .'participate.png', 'Participation Info for ' . $layer_name, 'showParticipationInfo', array($layer_tablename, $p_nid));
  }

  if($access) {
    addTool($xmlDoc, $toolsNode, 'download', $imgPath .'download-layertree.png', 'Download ' . $layer_name, 'getDownloadFormats', array($layer_tablename));
  }

  addTool($xmlDoc, $toolsNode, 'ZTE', $imgPath .'zoom-to-extent.png', 'Zoom to layer extent', 'zoomToExtent', array(getLayerExtent($layer_tablename,$layertype)));
}