$start = -1; $count = -1; } } /* if invalid return all elements*/ if ($start < 0 || $count < 0) { $start = 0; $count = $properties->{$layerName}->numelements; } //print_r($properties->$layerName); $result->{$layerName}->numelements = $count; $result->{$layerName}->values = array(); $result->{$layerName}->metadata = array(); $iIndice = 0; for ($j = $start; $j < $start + $count; $j++) { $szLayerProjection = getLayerProjection($oMap, $layerName); $oLayerExtents = $result->{$layerName}->bbox; if ($szLayerProjection) { if ($szLayerProjection != $oMapProjection) { $minx = $oLayerExtents->minx; $miny = $oLayerExtents->miny; $maxx = $oLayerExtents->maxx; $maxy = $oLayerExtents->maxy; reprojectPoint(&$minx, &$miny, $szLayerProjection, $oMapProjection); reprojectPoint(&$maxx, &$maxy, $szLayerProjection, $oMapProjection); $result->extents->minx = $minx; $result->extents->miny = $miny; $result->extents->maxx = $maxx; $result->extents->maxy = $maxy; } }
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); }