Skip to content

Instantly share code, notes, and snippets.

@silenius
Created February 11, 2015 14:57
Show Gist options
  • Save silenius/f0b0fb856b82a7c70eaa to your computer and use it in GitHub Desktop.
Save silenius/f0b0fb856b82a7c70eaa to your computer and use it in GitHub Desktop.
### PGSQL ###
create or replace view map_name as select id, name, now() as generated_date, st_GeomFromText('POINT(-5 70)') AS geom FROM map;
### MAPFILE ###
LAYER
NAME "mapname"
STATUS DEFAULT
TYPE POINT
#PROCESSING "CLOSE_CONNECTION=DEFER"
CONNECTIONTYPE OGR
CONNECTION "PG:host=127.0.0.1 dbname=xxx user=xxx password=xxx port=5432"
DATA "SELECT id, name, geom, generated_date FROM map_name WHERE id=%SPID%"
METADATA
"wms_title" "mapname"
END
VALIDATION
"SPID" "^[0-9]+$"
END
PROJECTION
"init=epsg:4326"
END
END
### SLD ###
<!-- MAP NAME LAYER -->
<NamedLayer>
<se:Name>mapname</se:Name>
<UserStyle>
<se:Name>mapname</se:Name>
<FeatureTypeStyle>
<se:Rule>
<se:Name>Map name</se:Name>
<se:TextSymbolizer>
<se:Label>
<ogc:PropertyName>name</ogc:PropertyName>
</se:Label>
<se:Fill>
<se:SvgParameter name="fill">#000000</se:SvgParameter>
</se:Fill>
<se:Font>
<se:SvgParameter name="font-family">vera</se:SvgParameter>
<se:SvgParameter name="font-style">normal</se:SvgParameter>
<se:SvgParameter name="font-weight">normal</se:SvgParameter>
<se:SvgParameter name="font-size">22</se:SvgParameter>
</se:Font>
</se:TextSymbolizer>
</se:Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment