[Geoprisma-dev] config.xml ideas : automatism
Stephen Woodbridge
woodbri at swoodbridge.com
Thu Dec 17 13:23:24 EST 2009
As I have mentioned in various discussion, I have a Perl script that I
use to generate my config.xml. It is just the collection of random
things that I have learned as I have gone through this process and I'm
sure it will not run for anyone else, but if you interested in taking a
quick look at some hackish unstructured code you are more then welcome.
To the points of automation:
1) it reads table schema information from the postgres database and uses
that to generate all the attribute definitions.
2) There are a bunch of globals the you can use to turn on/off
generation of features in the xml, like GYMO yes/no, which GYMO layers
you want, You can set NOEDIT to skip all the feature editing xml
generation, etc.
Since it is just a stream of if blocks as I have learned stuff, it is
quite the mess at the moment, and needs to be refactored. I am
considering rewriting it in PHP. One idea, way down the road, I have for
this is that it might be useful to automate downloading shapefiles and
adding them to a project and updating the config.xml. I also think the
having a metadata table in XML or a database that captured project
information would be help to drive an automated process.
Any for whatever it is worth, probably not much at this point, its attached.
Thanks all for the help and support so far.
-Steve
Yves Moisan wrote:
>> Overall, it is my newbie opinion that there appears to be a lot of
>> duplication.
>
> We all recognize that indeed. I also find things rather awkward to
> explain to our users here ...
>
>> I would like to describe more datastore or resource once
>> probably in more detail and then only reference it by name elsewhere.
>>
>> Having a datastore with 10 layers that might be used for either WMS or
>> WFS via featureserver should only require me to define it all in detail
>> in one place. Then things like featurepanel_form and layertree, etc
>> should look at that and configure themselves based on the information
>> available.
>>
>> For example, I find doing a querybyclick and a featurepanel_form to be
>> extremely redundant.
>
> I agree that widget interdependencies are somewhat arbitrary and would
> gain some fleshing out work. But do we go into that now ? One day or
> another we'll definitely have to address config.xml issues. When that
> day will be is the big question. Do we simplify GP use now at the
> expense of developing end user functionality ?
>
> At one point we had defined a number of milestones to call GP a "1.0"
> version. I have tentatively tried to organize Trac tickets in
> milestones, but some I intentionally left unassigned (in terms of
> version or milestone) because I don't know when they should be handled.
> An obvious printing story was definitely one of the milestones we wanted
> for a 1.0. My suggestion : let's define what we want for a 1.0, do
> that, then do a spin on simplifying the xml. Makes sense ?
>
>
>> Anyway, my two cents as someone very new to the project as a user.
>
> Thanx for sharing your thoughts !
>
> Yves
>
>
-------------- next part --------------
#!/usr/bin/perl -w
use strict;
use DBI;
use Data::Dumper;
my $DEBUG = 0;
my $NOGYMO = 1;
my $GYMO_GOOGLE = 1;
my $GYMO_OSM = 1;
my $GYMO_BING = 1;
my $GYMO_VEARTH = 0; # this is commented out in all the demos, so leave it off
my $GYMO_YAHOO = 1;
my $NOEDIT = 0;
my $NOZOOMSLIDER = 0;
my $NOTOOLBAR = 1;
#my $NOGEOTOOLBAR = 0;
my $MAXFEATURECNT = 100;
my $fxml = 'myconfig.xml';
my $server = 'imaptools.com:8080';
my $mapfile = '/home/woodbri/work/clients/mygov.us/corsicana/corsicana-900913-wms.map';
my $worldicon = 'img/zoom-world-mini.png';
my @tableorder = qw( onemileetj lakes parcels railroad fmroads serviceroads streets highways interstate votingprecincts zoning );
my %styleMapsClass;
initClassStyleMaps();
my %tableStyles = (
onemileetj => mkStyleMap('polygon','F6F7F6',0.4,'F3D7E1',1),
lakes => $styleMapsClass{lake},
parcels => mkStyleMap('polygon','FFFFFF',0.0,'FF7F7F',1),
railroad => $styleMapsClass{railroad},
fmroads => $styleMapsClass{road_6},
serviceroads => $styleMapsClass{road_5},
streets => $styleMapsClass{road_4},
highways => $styleMapsClass{road_2},
interstate => $styleMapsClass{road_1},
votingprecincts => mkStyleMap('polygon','FFFFFF',0,'FFFF7F',2),
zoning => mkStyleMap('polygon','FFFFFF',0,'7FFF7F',2),
citylimits => mkStyleMap('line','7F7F7F',1,'solid'),
);
Usage() unless scalar @ARGV;
my %opts = ();
while ($ARGV[0] =~ /^-/) {
my $o = shift @ARGV;
$opts{$o} = 1;
if ($o =~ /^-[n]/) {
$opts{$o} = shift @ARGV;
}
}
my $dbname = shift @ARGV || Usage();
my $dbhost = shift @ARGV || Usage();
my $dbuser = shift @ARGV || Usage();
my $dbpass = shift @ARGV || '';
sub Usage {
print "Usage: mk-geoprisma-config [<opt>] dbname dbhost dbuser [dbpass]\n";
print " <opt>\n";
print " -l list tables only\n";
print " -n table-names.txt load map of table to names\n";
print " -x generate myconfig.xml file\n";
exit(1);
}
my %tnames = ();
if ($opts{'-n'}) {
my $f = $opts{'-n'};
open(IN, "<$f") || die "Failed to open $f : $!\n";
while (my $x = <IN>) {
chomp($x);
my ($k, $v) = split(/\t/, $x);
$tnames{$k} = $v;
}
close(IN);
}
my $dsn = "dbi:Pg:database=$dbname;host=$dbhost";
my $dbh = DBI->connect($dsn, $dbuser, $dbpass,
{ RaiseError => 1, AutoCommit => 0 });
# get a lits of all tables in the "data" schema
my $sth = $dbh->table_info('', 'data', '%', 'TABLE');
# fetch schema and table names for above query
my $tables = $sth->fetchall_arrayref([1,2]);
$sth->finish;
# get the extents of all the tables
my $sql = 'select astext(expand(extent(the_geom), 100)) from (';
$sql .= join(" union all ", map {'select extent(the_geom) as the_geom from '.$_->[0].'.'.$_->[1]} @$tables);
$sql .= ') as foo';
$sth = $dbh->prepare($sql);
$sth->execute;
my $ext = $sth->fetchrow_array;
$sth->finish;
$ext =~ s/^POLYGON\(\(|\)\)\s*$//g;
my @ext = (split(/[\s,]+/, $ext))[0,1,4,5];
$ext = join(',', @ext);
# get the SRID for each of the tables
for (my $i=0; $i<@$tables; $i++) {
$sth = $dbh->prepare('select st_srid(the_geom) from ' .
$tables->[$i][0] . '.' . $tables->[$i][1]);
$sth->execute;
$tables->[$i][2] = 'EPSG:' . $sth->fetchrow_array;
$sth->finish;
}
#print Data::Dumper->Dump([$tables],['tables']);
# for each table get the list of column definitions
# TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, DATA_TYPE, TYPE_NAME,
# COLUMN_SIZE, BUFFER_LENGTH, DECIMAL_DIGITS, NUM_PREC_RADIX,
# NULLABLE(0,1,2), REMARKS, COLUMN_DEF, SQL_DATA_TYPE, SQL_DATETIME_SUB,
# CHAR_OCTET_LENGTH, ORDINAL_POSITION, IS_NULLABLE(NO,YES,'')
my %tables = ();
for my $x (@$tables) {
my $tn = $x->[0].'_'.$x->[1];
if ($opts{'-l'}) {
print "$tn = $tnames{$tn}\n";
}
else {
my $sth = $dbh->column_info('',$x->[0], $x->[1], '%');
my @cols = ();
while (my $r = $sth->fetchrow_hashref) {
push @cols, $r;
}
$tables{$tn} = \@cols;
}
$sth->finish;
}
$dbh->disconnect;
print Data::Dumper->Dump([\%tables],['tables'])
if $DEBUG;
exit(0) unless ($opts{'-x'});
# declare isbaselayer to true|false for the gymo layers
my $gymo = gymo();
# generate Geoprisma config.xml file
open(XML, ">$fxml") || die "Failed to open $fxml : $!\n";
print XML <<EOF;
<?xml version="1.0" encoding="iso-8859-1"?>
<geoprisma version="0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd">
<layouts>
<layout>
<name>default</name>
<file>default2.xslt</file>
<drawmode>extjs</drawmode>
</layout>
</layouts>
<services>
<wms>
<name>S_WMS_IMT_MS</name>
<srs>*</srs>
<format>*</format>
<source>http://$server/cgi-bin/mapserv?map=$mapfile</source>
</wms>
<!--wfs>
<name>S_WFS_IMT_TINYOWS</name>
<source>http://$server/cgi-bin/tinyows</source>
</wfs-->
<featureserver>
<name>S_WFS_IMT_FS</name>
<source>http://$server/cgi-bin/featureserver-1.12/featureserver.cgi</source>
</featureserver>
$gymo->{services}
</services>
<datastores>
<datastore>
<name>DS_WMS_BLANK</name>
<service>S_WMS_IMT_MS</service>
<params>
<layers>blank</layers>
</params>
</datastore>
EOF
my %resources = ();
for my $x (@$tables) {
my $tab = $x->[1];
my $tabU = uc($tab);
my $tn = $x->[0].'_'.$x->[1];
my $tnU = uc($tn);
# get the column info about this table
my $cols = $tables{$tn};
# find what type of geometry we have
my $gtype = 'unknown';
for my $col (@$cols) {
if ($col->{pg_type} eq 'geometry' && $col->{pg_constraint}) {
if ($col->{pg_constraint} =~ /'([^\\]+)'/) {
$gtype = $1;
$gtype = 'MultiPoint' if $gtype =~ /^MultiPoint$/i;
$gtype = 'Point' if $gtype =~ /^Point$/i;
$gtype = 'MultiLineString' if $gtype =~ /^multiLineString$/i;
$gtype = 'LineString' if $gtype =~ /^LineString$/i;
$gtype = 'MultiPolygon' if $gtype =~ /^MultiPolygon$/i;
$gtype = 'Polygon' if $gtype =~ /^Polygon$/i;
last;
}
}
}
$resources{$tab} = {
geometrytype => $gtype,
basename => $tabU,
name => "R_$tabU",
datastores => ["DS_WMS_$tabU"],
widgets => [],
};
unless ($NOEDIT) {
push @{$resources{$tab}->{datastores}}, "DS_WFS_$tabU";
$resources{$tab}->{widgets} = ["Create_$tabU", "Update_$tabU", "Delete_$tabU", "FeaturePanelForm_$tabU"];
}
# output the XML file
print XML <<EOF;
<datastore>
<name>DS_WMS_$tabU</name>
<service>S_WMS_IMT_MS</service>
<params>
<layers>$tab</layers>
</params>
</datastore>
EOF
unless ($NOEDIT) {
print XML <<EOF;
<datastore>
<name>DS_WFS_$tabU</name>
<service>S_WFS_IMT_FS</service>
<params>
<layers>$tab</layers>
<name>$tab</name>
<text>$tnames{$tn}</text>
<geometrytypes>
<geometrytype>$gtype</geometrytype>
</geometrytypes>
<fields>
EOF
for my $col (@$cols) {
my $cname = $col->{COLUMN_NAME};
my $dtype = $col->{TYPE_NAME};
next if $dtype eq 'geometry';
next if $cname eq 'gid';
print XML <<EOF;
<field>
<name>$cname</name>
<text>$cname</text>
<type>$dtype</type>
<!-- NB: optionally add list of values -->
</field>
EOF
}
print XML <<EOF;
</fields>
</params>
</datastore>
EOF
}
}
print XML <<EOF;
$gymo->{datastores}
</datastores>
<widgets>
<map>
<name>DefaultMap</name>
<options>
<units>m</units>
<projection>EPSG:900913</projection>
<maxextent>-20037508.34,-20037508.34,20037508.34,20037508.34</maxextent>
<displayprojection>EPSG:4326</displayprojection>
<numzoomlevels>19</numzoomlevels>
<maxresolution>156543.0339</maxresolution>
<alloverlays>false</alloverlays>
</options>
<layers>
<layer>
<resourcenames>
<resourcename>BLANKResource</resourcename>
</resourcenames>
<servicetype>wms</servicetype>
<options>
<layername>WMS_BLANK</layername>
<isbaselayer>true</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<format>image/png</format>
<transparent>false</transparent>
<singletile>true</singletile>
<ratio>1.0</ratio>
<visibility>true</visibility>
</options>
</layer>
<!-- ADD GYMO LAYERS HERE -->
<!-- ADD GYMO LAYERS HERE -->
$gymo->{maplayers}
<!-- ADD ALL OUR WMS LAYERS HERE -->
<!-- ADD ALL OUR WMS LAYERS HERE -->
<layer>
<resourcenames>
EOF
for my $x (@tableorder) {
my $y = $resources{$x}->{name};
print XML <<EOF;
<resourcename>$y</resourcename>
EOF
}
print XML <<EOF;
</resourcenames>
<servicetype>wms</servicetype>
<options>
<layername>WMS_ALL_LAYER</layername>
<isbaselayer>false</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<format>image/png</format>
<transparent>true</transparent>
<singletile>true</singletile>
<ratio>1.0</ratio>
<visibility>true</visibility>
</options>
</layer>
<!-- ADD ALL OUR WFS LAYERS HERE -->
<!-- ADD ALL OUR WFS LAYERS HERE -->
EOF
unless ($NOEDIT) {
for my $x (@tableorder) {
my $y = $resources{$x}->{name};
my $layername = 'WFS_' . $resources{$x}->{basename};
print XML <<EOF;
<layer>
<resourcenames>
<resourcename>$y</resourcename>
</resourcenames>
<servicetype>featureserver</servicetype>
<options>
<layername>$layername</layername>
<isbaselayer>false</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<maxfeatures>$MAXFEATURECNT</maxfeatures>
<extractAttributes>true</extractAttributes>
<scales>50000,25000,10000,5000,2500,1000</scales>
<visibility>true</visibility>
EOF
my $map = $tableStyles{$x};
outputStyleMap($map) if $map;
print XML <<EOF;
</options>
</layer>
EOF
}
}
print XML <<EOF;
</layers>
</map>
<mapfishlayertree>
<name>LegendDemo</name>
<options>
<showWmsLegend>true</showWmsLegend>
<enableDD>true</enableDD>
<model>
<node>
<textkey>All Layers</textkey>
<checked>undefined</checked>
<icon>$worldicon</icon>
<children>
<node>
<textkey>Base Layers</textkey>
<checked>undefined</checked>
<icon>$worldicon</icon>
<children>
<node>
<layername>WMS_BLANK</layername>
<resourcename>BLANKResource</resourcename>
<textkey>Blank Background</textkey>
<checked>true</checked>
</node>
$gymo->{mapfishlayertree}
</children>
</node>
EOF
print XML <<EOF;
<node>
<textkey>WMS Overlays</textkey>
<expanded>true</expanded>
<checked>true</checked>
<icon>$worldicon</icon>
<children>
<!-- ADD OUR WMS OVERLAY LAYERS HERE -->
<!-- ADD OUR WMS OVERLAY LAYERS HERE -->
EOF
for my $x (@tableorder) {
my $table = $resources{$x}->{basename};
my $resourcename = $resources{$x}->{name};
#my $layername = 'WMS_' . $resources{$x}->{basename};
my $layername = 'WMS_ALL_LAYER';
print XML <<EOF;
<node>
<layername>$layername</layername>
<resourcename>$resourcename</resourcename>
<textkey>$table</textkey>
<checked>true</checked>
</node>
EOF
}
print XML <<EOF;
</children>
</node>
EOF
unless ($NOEDIT) {
print XML <<EOF;
<node>
<textkey>Vector Layers</textkey>
<expanded>true</expanded>
<checked>false</checked>
<icon>$worldicon</icon>
<children>
<!-- ADD OUR VECTOR OVERLAY LAYERS HERE -->
<!-- ADD OUR VECTOR OVERLAY LAYERS HERE -->
EOF
for my $x (@tableorder) {
my $table = $resources{$x}->{basename};
my $resourcename = $resources{$x}->{name};
my $layername = 'WFS_' . $resources{$x}->{basename};
print XML <<EOF;
<node>
<layername>$layername</layername>
<resourcename>$resourcename</resourcename>
<textkey>$table</textkey>
<checked>false</checked>
<maxScale>50000</maxScale>
</node>
EOF
}
print XML <<EOF;
</children>
</node>
EOF
}
print XML <<EOF;
</children>
</node>
</model>
</options>
</mapfishlayertree>
EOF
# add editfeature_* widgets
unless ($NOEDIT) {
for my $x (@tableorder) {
my $basename = $resources{$x}{basename};
my $geometry = $resources{$x}{geometrytype};
print XML <<EOF;
<editfeature_create>
<name>Create_$basename</name>
<options>
<geometrytype>$geometry</geometrytype>
<featurepanel>FeaturePanelForm_$basename</featurepanel>
</options>
</editfeature_create>
<editfeature_update>
<!--title>Modify a feature on the map</title-->
<name>Update_$basename</name>
<options>
<editgeom>true</editgeom>
<featurepanel>FeaturePanelForm_$basename</featurepanel>
</options>
</editfeature_update>
<editfeature_delete>
<name>Delete_$basename</name>
<options>
<featurecontroloptions>
<multiple>true</multiple>
<box>false</box>
</featurecontroloptions>
</options>
</editfeature_delete>
EOF
}
}
# add featurepanel widgets here
# xtype: combo, textfield, displayfield
# COLUMN_SIZE
unless ($NOEDIT) {
for my $x (@$tables) {
my $tab = $x->[1];
my $tabU = uc($tab);
my $tn = $x->[0].'_'.$x->[1];
my $tnU = uc($tn);
# get the column info about this table
my $cols = $tables{$tn};
print XML <<EOF;
<featurepanel_form>
<name>FeaturePanelForm_$tabU</name>
<options>
<!--title>$tabU</title-->
<inwindow>true</inwindow>
<windowoffset>
<left>100</left>
</windowoffset>
<windowoptions>
<title>$tabU</title>
<!--modal>true</modal-->
<height>350</height>
<width>400</width>
</windowoptions>
<autoScroll>true</autoScroll>
<defaults>
<width>150</width>
</defaults>
<fields>
EOF
for my $col (@$cols) {
my $cname = $col->{COLUMN_NAME};
my $dtype = $col->{TYPE_NAME};
next if $dtype eq 'geometry';
my $dwidth = $col->{COLUMN_SIZE} || '25';
my $xtype = 'textfield';
if ($cname eq 'gid') {
$dwidth = '25';
$xtype = 'displayfield';
}
$dwidth = '10' if 0+$dwidth < 10;
print XML <<EOF;
<field>
<name>$cname</name>
<xtype>$xtype</xtype>
<!--width>$dwidth</width-->
</field>
EOF
}
print XML <<EOF;
</fields>
</options>
</featurepanel_form>
EOF
}
}
print XML <<EOF;
<legendpanel>
<name>LegendPanel</name>
<options>
<title>Legend Panel</title>
</options>
</legendpanel>
EOF
unless ($NOTOOLBAR) {
print XML <<EOF;
<toolbar>
<name>Toolbar</name>
<options>
<widgets>
</widgets>
</options>
</toolbar>
EOF
}
print XML <<EOF;
<geoexttoolbar>
<name>GeoExtToolbar</name>
<options>
<widgets>
EOF
# <!--widget>QueryOnClickDemo</widget-->
# add the layer related widgets to the geoexttoolbar
unless ($NOEDIT) {
for my $x (@tableorder) {
for my $y (@{$resources{$x}->{widgets}}) {
print XML <<EOF;
<widget>$y</widget>
EOF
}
}
}
print XML <<EOF;
</widgets>
</options>
</geoexttoolbar>
<mouseposition>
<name>MousePositionName</name>
<options>
</options>
</mouseposition>
<scale>
<name>ScaleName</name>
<options>
</options>
</scale>
EOF
unless ($NOZOOMSLIDER) {
print XML <<EOF;
<zoomslider>
<name>ZoomSliderTool</name>
<options>
</options>
</zoomslider>
EOF
}
print XML <<EOF;
</widgets>
<resources>
<resource>
<name>BLANKResource</name>
<datastores>
<datastore>DS_WMS_BLANK</datastore>
</datastores>
<widgets>
EOF
unless ($NOZOOMSLIDER) {
print XML <<EOF;
<widget>ZoomSliderTool</widget>
EOF
}
unless ($NOTOOLBAR) {
print XML <<EOF;
<widget>Toolbar</widget>
EOF
}
print XML <<EOF;
<widget>GeoExtToolbar</widget>
<widget>MousePositionName</widget>
<widget>ScaleName</widget>
</widgets>
</resource>
$gymo->{resources}
EOF
for my $y (@tableorder) {
my $x = $resources{$y};
print XML <<EOF;
<resource>
<name>$x->{name}</name>
<datastores>
<datastore>$x->{datastores}[0]</datastore>
EOF
unless ($NOEDIT) {
print XML <<EOF;
<datastore>$x->{datastores}[1]</datastore>
EOF
}
print XML <<EOF;
</datastores>
<widgets>
EOF
# add the layer related widgets to the to the resource
unless ($NOEDIT) {
for my $y (@{$x->{widgets}}) {
print XML <<EOF;
<widget>$y</widget>
EOF
}
}
print XML <<EOF;
</widgets>
</resource>
EOF
}
print XML <<EOF;
</resources>
</geoprisma>
EOF
close(XML);
exit;
sub outputStyleMap {
my $map = shift;
print XML <<EOF;
<stylemap>
<renderers>
EOF
foreach my $x (qw(default select delete)) {
print XML <<EOF;
<renderer>
<renderintent>$x</renderintent>
<style>
EOF
foreach my $k (sort keys %{$map->{$x}}) {
print XML <<EOF;
<$k>$map->{$x}{$k}</$k>
EOF
}
print XML <<EOF;
</style>
</renderer>
EOF
}
print XML <<EOF;
</renderers>
</stylemap>
EOF
}
sub mkStyleMap {
my $type = shift;
my %style;
if ($type eq 'polygon') {
my ($fill, $opac, $stroke, $swidth) = @_;
%style = (
default => {
strokecolor => $stroke,
strokewidth => $swidth,
fillcolor => $fill,
fillopacity => $opac,
},
'select' => {
strokecolor => 'FF0000',
strokewidth => $swidth,
fillcolor => 'FF0000',
fillopacity => $opac,
},
'delete' => {
strokecolor => '000000',
strokewidth => $swidth,
},
);
}
elsif ($type eq 'line') {
my ($stroke, $swidth, $lstyle) = @_;
$lstyle ||= 'solid';
%style = (
default => {
strokecolor => $stroke,
strokewidth => $swidth,
strokedashstyle => $lstyle,
},
'select' => {
strokecolor => 'FF0000',
strokewidth => $swidth,
},
'delete' => {
strokecolor => '000000',
strokewidth => $swidth,
},
);
}
elsif ($type eq 'point') {
my ($fill, $opac, $stroke, $swidth, $radius) = @_;
%style = (
default => {
fillcolor => $fill,
fillopacity => $opac,
strokecolor => $stroke,
strokewidth => $swidth,
pointRadius => $radius,
radius => $radius,
},
'select' => {
strokecolor => 'FF0000',
strokewidth => $swidth,
fillcolor => 'FF0000',
fillopacity => $opac,
},
'delete' => {
strokecolor => '000000',
strokewidth => $swidth,
},
);
}
else {
warn "mkStyleMap: invalid type: $type \n";
}
return \%style;
}
sub initClassStyleMaps {
%styleMapsClass = (
road_1 => {
default => { strokecolor => 'BD5E3B', strokewidth => '5', },
'select' => { strokecolor => 'FF0000', strokewidth => '5', },
'delete' => { strokecolor => '000000', strokewidth => '5', },
},
road_2 => {
default => { strokecolor => 'FDB462', strokewidth => '5', },
'select' => { strokecolor => 'FF0000', strokewidth => '5', },
'delete' => { strokecolor => '000000', strokewidth => '5', },
},
road_3 => {
default => { strokecolor => 'FBCD08', strokewidth => '5', },
'select' => { strokecolor => 'FF0000', strokewidth => '5', },
'delete' => { strokecolor => '000000', strokewidth => '5', },
},
road_4 => {
default => { strokecolor => 'C8C0B4', strokewidth => '3', },
'select' => { strokecolor => 'FF0000', strokewidth => '3', },
'delete' => { strokecolor => '000000', strokewidth => '3', },
},
road_5 => {
default => { strokecolor => 'CCCCCC', strokewidth => '2', },
'select' => { strokecolor => 'FF0000', strokewidth => '2', },
'delete' => { strokecolor => '000000', strokewidth => '2', },
},
road_6 => {
default => { strokecolor => 'CCCCCC', strokewidth => '2', strokedashstyle => 'dash', },
'select' => { strokecolor => 'FF0000', strokewidth => '2', },
'delete' => { strokecolor => '000000', strokewidth => '2', },
},
railroad => {
default => { strokecolor => '000000', strokewidth => '2', strokedashstyle => 'longdash', },
'select' => { strokecolor => 'FF0000', strokewidth => '2', },
'delete' => { strokecolor => '000000', strokewidth => '2', },
},
river => {
default => { strokecolor => '80B1E3', strokewidth => '2', },
'select' => { strokecolor => 'FF0000', strokewidth => '2', },
'delete' => { strokecolor => '000000', strokewidth => '2', },
},
lake => {
default => { strokecolor => '80B1E3', strokewidth => '2',
fillcolor => '80B1D3', fillopacity => 0.6, },
'select' => { strokecolor => 'FF0000', strokewidth => '2',
fillcolor => '80B1D3', fillopacity => 0.6, },
'delete' => { strokecolor => '000000', strokewidth => '2',
fillcolor => '80B1D3', fillopacity => 0.6, },
},
);
}
sub gymo {
my $isbaselayer = shift || 'true';
my %gymo = ();
if ($NOGYMO) {
$gymo{services} = '';
$gymo{datastores} = '';
$gymo{maplayers} = '';
$gymo{mapfishlayertree} = '';
$gymo{resources} = '';
return \%gymo;
}
if ($GYMO_GOOGLE) {
$gymo{services} .= <<EOF;
<gymo>
<name>GoogleMaps</name>
<provider>google</provider>
<apikey>ABQIAAAA72QmL2IvdGAtgjbXsO9bhBTrT8YlCqZKH0aoBJtyqmXyciyx2RTaQRZTOOck6lfjLRMY6qN2ydwIQQ</apikey>
<source>http://maps.google.com/maps?file=api&v=2&sensor=false&</source>
</gymo>
EOF
}
if ($GYMO_OSM) {
$gymo{services} .= <<EOF;
<gymo>
<name>OpenStreetMap</name>
<provider>openstreetmap</provider>
<source>http://tile.openstreetmap.org/</source>
</gymo>
EOF
}
if ($GYMO_BING) {
$gymo{services} .= <<EOF;
<gymo>
<name>MS_BING</name>
<provider>bing</provider>
<source>http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2&mkt=en-us</source>
</gymo>
EOF
}
if ($GYMO_VEARTH) {
$gymo{services} .= <<EOF;
<gymo>
<name>MS_VirtualEarth</name>
<provider>virtualearth</provider>
<source>http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1</source>
</gymo>
EOF
}
if ($GYMO_YAHOO) {
$gymo{services} .= <<EOF;
<gymo>
<name>YahooMaps</name>
<provider>yahoo</provider>
<source>http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=ttja2AnV34EW8qc5o6Fwgk45Hr7lUp04A8mYT_.SJgfMPEOcNBRLcOMTHj.jpSA-</source>
</gymo>
EOF
}
if ($GYMO_GOOGLE) {
$gymo{datastores} .= <<EOF;
<datastore>
<name>DS_Google_Streets</name>
<service>GoogleMaps</service>
<params>
<layers>streets</layers>
</params>
</datastore>
<datastore>
<name>DS_Google_Hybrid</name>
<service>GoogleMaps</service>
<params>
<layers>hybrid</layers>
</params>
</datastore>
<datastore>
<name>DS_Google_Satellite</name>
<service>GoogleMaps</service>
<params>
<layers>satellite</layers>
</params>
</datastore>
<datastore>
<name>DS_Google_Physical</name>
<service>GoogleMaps</service>
<params>
<layers>physical</layers>
</params>
</datastore>
EOF
}
if ($GYMO_OSM) {
$gymo{datastores} .= <<EOF;
<datastore>
<name>DS_OSM</name>
<service>OpenStreetMap</service>
<params>
</params>
</datastore>
EOF
}
if ($GYMO_BING) {
$gymo{datastores} .= <<EOF;
<datastore>
<name>DS_Bing_Shaded</name>
<service>MS_BING</service>
<params>
<layers>shaded</layers>
</params>
</datastore>
<datastore>
<name>DS_Bing_Hybrid</name>
<service>MS_BING</service>
<params>
<layers>hybrid</layers>
</params>
</datastore>
<datastore>
<name>DS_Bing_Aerial</name>
<service>MS_BING</service>
<params>
<layers>aerial</layers>
</params>
</datastore>
EOF
}
if ($GYMO_VEARTH) {
$gymo{datastores} .= <<EOF;
<datastore>
<name>DS_VE_Road</name>
<service>MS_VirtualEarth</service>
<params>
<layers>road</layers>
</params>
</datastore>
<datastore>
<name>DS_VE_Hybrid</name>
<service>MS_VirtualEarth</service>
<params>
<layers>hybrid</layers>
</params>
</datastore>
<datastore>
<name>DS_VE_Aerial</name>
<service>MS_VirtualEarth</service>
<params>
<layers>aerial</layers>
</params>
</datastore>
EOF
}
if ($GYMO_YAHOO) {
$gymo{datastores} .= <<EOF;
<datastore>
<name>DS_Yahoo_Street</name>
<service>YahooMaps</service>
<params>
<layers>street</layers>
</params>
</datastore>
<datastore>
<name>DS_Yahoo_Hybrid</name>
<service>YahooMaps</service>
<params>
<layers>hybrid</layers>
</params>
</datastore>
<datastore>
<name>DS_Yahoo_Satellite</name>
<service>YahooMaps</service>
<params>
<layers>satellite</layers>
</params>
</datastore>
EOF
}
if ($GYMO_GOOGLE) {
$gymo{maplayers} .= <<EOF;
<layer>
<resourcenames>
<resourcename>GoogleStreetResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRGoogleStreet</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>GoogleSatelliteResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRGoogleSatellite</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>GoogleHybridResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRGoogleHybrid</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>GooglePhysicalResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRGooglePhysical</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
EOF
}
if ($GYMO_OSM) {
$gymo{maplayers} .= <<EOF;
<layer>
<resourcenames>
<resourcename>OSMResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYROSM</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
EOF
}
if ($GYMO_BING) {
$gymo{maplayers} .= <<EOF;
<layer>
<resourcenames>
<resourcename>BingShadedResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRBingShaded</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>BingHybridResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRBingHybrid</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>BingAerialResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRBingAerial</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
EOF
}
if ($GYMO_VEARTH) {
$gymo{maplayers} .= <<EOF;
<!--layer>
<resourcenames>
<resourcename>VERoadResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRVERoad</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>VEHybridResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRVEHybrid</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>VEAerialResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRVEAerial</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer-->
EOF
}
if ($GYMO_YAHOO) {
$gymo{maplayers} .= <<EOF;
<layer>
<resourcenames>
<resourcename>YahooStreetResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRYahooStreet</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>YahooSatelliteResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRYahooSatellite</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
<layer>
<resourcenames>
<resourcename>YahooHybridResource</resourcename>
</resourcenames>
<servicetype>gymo</servicetype>
<options>
<layername>LYRYahooHybrid</layername>
<isbaselayer>$isbaselayer</isbaselayer>
<projection>EPSG:900913</projection>
<sphericalmercator>true</sphericalmercator>
<minzoomlevel>2</minzoomlevel>
</options>
</layer>
EOF
}
if ($GYMO_OSM) {
$gymo{mapfishlayertree} .= <<EOF;
<node>
<layername>LYROSM</layername>
<resourcename>OSMResource</resourcename>
<textkey>OpenStreetMap</textkey>
</node>
EOF
}
if ($GYMO_GOOGLE) {
$gymo{mapfishlayertree} .= <<EOF;
<node>
<textkey>Google Layers</textkey>
<expanded>false</expanded>
<checked>undefined</checked>
<children>
<node>
<layername>LYRGoogleStreet</layername>
<resourcename>GoogleStreetResource</resourcename>
<textkey>Google Streets</textkey>
</node>
<node>
<layername>LYRGoogleSatellite</layername>
<resourcename>GoogleSatelliteResource</resourcename>
<textkey>Google Satellite</textkey>
</node>
<node>
<layername>LYRGoogleHybrid</layername>
<resourcename>GoogleHybridResource</resourcename>
<textkey>Google Hybrid</textkey>
</node>
<node>
<layername>LYRGooglePhysical</layername>
<resourcename>GooglePhysicalResource</resourcename>
<textkey>Google Physical</textkey>
</node>
</children>
</node>
EOF
}
if ($GYMO_BING) {
$gymo{mapfishlayertree} .= <<EOF;
<node>
<textkey>Bing Layers</textkey>
<expanded>false</expanded>
<checked>undefined</checked>
<children>
<node>
<layername>LYRBingShaded</layername>
<resourcename>BingShadedResource</resourcename>
<textkey>Bing Shaded</textkey>
</node>
<node>
<layername>LYRBingAerial</layername>
<resourcename>BingAerialResource</resourcename>
<textkey>Bing Aerial</textkey>
</node>
<node>
<layername>LYRBingHybrid</layername>
<resourcename>BingHybridResource</resourcename>
<textkey>Bing Hybrid</textkey>
</node>
</children>
</node>
EOF
}
if ($GYMO_VEARTH) {
$gymo{mapfishlayertree} .= <<EOF;
<node>
<textkey>Virtual Earth Layers</textkey>
<expanded>false</expanded>
<checked>undefined</checked>
<children>
<node>
<layername>LYRVERoad</layername>
<resourcename>VERoadResource</resourcename>
<textkey>VE Roads</textkey>
</node>
<node>
<layername>LYRVEAerial</layername>
<resourcename>VEAerialResource</resourcename>
<textkey>VE Aerial</textkey>
</node>
<node>
<layername>LYRVEHybrid</layername>
<resourcename>VEHybridResource</resourcename>
<textkey>VE Hybrid</textkey>
</node>
</children>
</node>
EOF
}
if ($GYMO_YAHOO) {
$gymo{mapfishlayertree} .= <<EOF;
<node>
<textkey>Yahoo Layers</textkey>
<expanded>false</expanded>
<checked>undefined</checked>
<children>
<node>
<layername>LYRYahooStreet</layername>
<resourcename>YahooStreetResource</resourcename>
<textkey>Yahoo! Streets</textkey>
</node>
<node>
<layername>LYRYahooSatellite</layername>
<resourcename>YahooSatelliteResource</resourcename>
<textkey>Yahoo! Satellite</textkey>
</node>
<node>
<layername>LYRYahooHybrid</layername>
<resourcename>YahooHybridResource</resourcename>
<textkey>Yahoo! Hybrid</textkey>
</node>
</children>
</node>
EOF
}
if ($GYMO_GOOGLE) {
$gymo{resources} .= <<EOF;
<resource>
<name>GoogleStreetResource</name>
<datastores>
<datastore>DS_Google_Streets</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>GoogleSatelliteResource</name>
<datastores>
<datastore>DS_Google_Satellite</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>GoogleHybridResource</name>
<datastores>
<datastore>DS_Google_Hybrid</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>GooglePhysicalResource</name>
<datastores>
<datastore>DS_Google_Physical</datastore>
</datastores>
<widgets>
</widgets>
</resource>
EOF
}
if ($GYMO_OSM) {
$gymo{resources} .= <<EOF;
<resource>
<name>OSMResource</name>
<datastores>
<datastore>DS_OSM</datastore>
</datastores>
<widgets>
</widgets>
</resource>
EOF
}
if ($GYMO_BING) {
$gymo{resources} .= <<EOF;
<resource>
<name>BingShadedResource</name>
<datastores>
<datastore>DS_Bing_Shaded</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>BingHybridResource</name>
<datastores>
<datastore>DS_Bing_Hybrid</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>BingAerialResource</name>
<datastores>
<datastore>DS_Bing_Aerial</datastore>
</datastores>
<widgets>
</widgets>
</resource>
EOF
}
if ($GYMO_VEARTH) {
$gymo{resources} .= <<EOF;
<resource>
<name>VERoadResource</name>
<datastores>
<datastore>DS_VE_Road</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>VEHybridResource</name>
<datastores>
<datastore>DS_VE_Hybrid</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>VEAerialResource</name>
<datastores>
<datastore>DS_VE_Aerial</datastore>
</datastores>
<widgets>
</widgets>
</resource>
EOF
}
if ($GYMO_YAHOO) {
$gymo{resources} .= <<EOF;
<resource>
<name>YahooStreetResource</name>
<datastores>
<datastore>DS_Yahoo_Street</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>YahooSatelliteResource</name>
<datastores>
<datastore>DS_Yahoo_Satellite</datastore>
</datastores>
<widgets>
</widgets>
</resource>
<resource>
<name>YahooHybridResource</name>
<datastores>
<datastore>DS_Yahoo_Hybrid</datastore>
</datastores>
<widgets>
</widgets>
</resource>
EOF
}
return \%gymo;
}
More information about the Geoprisma-dev
mailing list