public prepareRowAsOl ( string $spatial, integer $srid, string $label, string $fill_color, array $scale_data ) : string | ||
$spatial | string | GIS POLYGON object |
$srid | integer | Spatial reference ID |
$label | string | Label for the GIS POLYGON object |
$fill_color | string | Color for the GIS POLYGON object |
$scale_data | array | Array containing data related to scaling |
Результат | string | JavaScript related to a row in the GIS dataset |
public function prepareRowAsOl($spatial, $srid, $label, $fill_color, $scale_data)
{
$style_options = array('strokeColor' => '#000000', 'strokeWidth' => 0.5, 'fillColor' => $fill_color, 'fillOpacity' => 0.8, 'label' => $label, 'fontSize' => 10);
if ($srid == 0) {
$srid = 4326;
}
$row = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = mb_substr($spatial, 9, mb_strlen($spatial) - 11);
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(' . $this->getPolygonForOpenLayers($parts, $srid) . ', null, ' . json_encode($style_options) . '));';
return $row;
}
/** * test case for prepareRowAsOl() method * * @param string $spatial GIS POLYGON object * @param int $srid spatial reference ID * @param string $label label for the GIS POLYGON object * @param string $fill_color color for the GIS POLYGON object * @param array $scale_data array containing data related to scaling * @param string $output expected output * * @return void * @dataProvider providerForPrepareRowAsOl */ public function testPrepareRowAsOl( $spatial, $srid, $label, $fill_color, $scale_data, $output ) { $this->assertEquals( $output, $this->object->prepareRowAsOl( $spatial, $srid, $label, $fill_color, $scale_data ) ); }