Back to <a Berlin Index</a><hr>
<h3>Where we are</h3>
<table cellspacing="6" cellpadding="6" bgcolor="#b0f0b0"><tr><td>
Since now in this tutorial we've simply examined the external skin of the <b>Rendering Engine</b> implemented by <b>librasterlite2</b> and directly integrated in <b>spatialite_gui</b> via its <b>Map Panel</b>.<br>
It's now time to come down to greater depth so to appreciate all the revolutionary power it can offer.<br><br>
<b>Be prepared for unexpected surprises.</b>

<br><br>
<hr>
<h3>First surprise: Styled Maps can be created by pure SQL statements</h3>
The <b>Rendering Engine</b> (and all that it implies in terms of <b>Styled Map Layers</b>) is fully implemented by <b>librasterlite2</b>, that actually is a <b>dymanic extension</b> expanding the basic SQL capabilities of <b>SQLite</b>.<br>
This practically means that complex richly styled Maps can be created in the easiest way by just executing some appropriate SQL statement.<br><br>
Such a capability immediately opens the doors for an easy and simple integration of the <b>Rendering Engine</b> in whatever programming language: <b>Java</b>, <b>Python</b>, <b>PHP</b> and many others.<br>
The basic approach will always be exactly the same for all them:
<ol>
<li>Establish a connection to the SQLite database containing the Map by using the <b>language bindings</b> for your specific language.</li>
<li>Then load both extensions <b>SpatiaLite</b> and
<li>Now you'll be ready for executing any <b>RasterLite2</b> SQL function returning a <b>Styled Map</b><ul>
<li>Each function will then return a <b>BLOB</b> object containing the <b>image</b> corresponding to your request.</li>
<li>At this point your program will simply take some appropriate action (as e.g. displaying the image on the screen) and that's all.</li>

</ol>
Said in other words: developing a feature rich Map Viewer tool will just require to implement the interactive <b>zoom and pan</b> logic.<br>
Any other related task will then directly delegated to the SQL level. Your program will be just required to manage some appropriate <b>SQL query</b>
<ul>
Note that this is an almost universally portable architecture available on practically any of the most common programming languages requiring only few very basic prerequisites:<ul>
<li>Support for some kind of SQLite connector being enabled to dynamically load extension modules.</li>
<li>Installing both <b>SpatiaLite</b> and <b>RasterLite2</b> extensions.</li>

</ul><br>
A practical example based on the <b>OSM Berlin Map</b>
<verbatim>
SELECT RL2_GetImageFromMapConfiguration('osm-berlin',
       BuildMbr(391981.48944364, 5820790.78669314, 392990.18818636, 5821799.48543586, 25833),
       1024, 1024,
       'image/png');
</verbatim>
<ol>
<li>the first argument corresponds to the <b>Map Configuration name</b> (expected to exists into the connected database).</li>
<li>the second argument corresponds to the <b>Bounding Box</b> to be covered by the <b>image</b> to be created.</li>
<li>the third and fourth arguments respectively are the <b>width</b> and <b>heigth</b> (in pixels) pf the image.</li>
<li>and finally the fifth argumets is the <b>MIME type</b> identified the format of the BLOB image to be returned.<br>
The following <b>MIME types</b> are supported:<ul>
TRUE color (RGB) PNG</li>
grayscale or palette based PNG (8 bits X pixel)</li>
GIF</li>
JPEG compressed image</li>
TRUE color (RGB) TIFF</li>
grayscale or palette based TIFF (8 bits X pixel)</li>
TRUE color (RGB) GeoTIFF</li>
grayscale or palette based GeoTIFF (8 bits X pixel)</li>
or PDF document</li>
a flat RGBA matrix of HEIGHT scanlines (from top to bottom)<br>
Each scanline contains WIDTH pixels (from left to right)<br>
Pixels are strictly packed, each one of them requiring 4 bytes. (<b>Red</b>, <b>Green</b>, <b>Blue</b> and <b>Alpha</b> channels).<br>
<b>Note</b>: this specific format usually corresponds to the native one supported by many screen devices.</li>

</ol>
<img alt="blob-img-1" border="1">
<br>This is the PNG image returned by the previous SQL Query.<br><br>
<hr>
<h3>Second surprise: Styled Maps are always ready to be immediately published as WMS - Web Map Services</h3>
More precisely, it just requires to create an <b>XLM file</b> defining the WMS service you intend to publish on the WEB.<br>
Dpn't worry, it's a very simple step fully supported by a specific <b>GUI Wizard</b>
<table width="100%" cellspacing="6" cellpadding="6" border="1">
<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-01">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-02">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-03">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-04">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-05">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-06">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-07">

</table>
azbratovar
<table width="100%" cellspacing="6" cellpadding="6" border="1">
<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-08">

<tr><td>
piro piro
</td><td width="60%" align="center"><img alt="wms-09">

<tr><td colspan="2">
stozzac
<verbatim>
<?xml version="1.0" encoding="UTF-8"?>
<!-- created by spatialite_gui on 2022-06-04 11:08:51 -->
<WmsLiteConfig version="1.0"


  >
	<Service>
		<Name>WMS</Name>
		<Title>WmsLite test server</Title>
		<Abstract>A simple light-weight WMS server for testing RasterLite2 Coverages.</Abstract>
		<KeywordList>
				<Keyword>some keyword</Keyword>
				<Keyword>another keyword</Keyword>
		</KeywordList>

		<ContactInformation>
			<ContactPersonPrimary>
				<ContactPerson>James T. Kirk</ContactPerson>
				<ContactOrganization>United Federation of Planets, Starfleet</ContactOrganization>
			</ContactPersonPrimary>
			<ContactPosition>Starship Captain</ContactPosition>
			<ContactAddress>
				<AddressType>stellar</AddressType>
				<Address>USS Enterprise</Address>
				<City>Planet Earth</City>
				<StateOrProvince>Solar System</StateOrProvince>

				<Country>Milky Way Galaxy</Country>
			</ContactAddress>

		</ContactInformation>
		<Fees>none</Fees>
		<AccessConstraints>none</AccessConstraints>
		<LayerLimit>10</LayerLimit>
		<MaxWidth>5000</MaxWidth>
		<MaxHeight>5000</MaxHeight>
	</Service>
	<GeneralOptions>
		<MultiThreading Enabled="true" MaxThreads="8" />
		<WMS MaxRetries="5" Pause="5" />
		<Background Color="#f2efe9" Transparent="false" />
		<LabelAdvancedOptions AntiCollisionEnabled="true" WrapTextEnabled="true" AutoRotateEnabled="false" ShiftPositionEnabled="false" />
	</GeneralOptions>
	<WmsLayers>
		<TopLevelLayer>
			<Title>Top Level Layer</Title>
		</TopLevelLayer>
		<MainDB
			<Layer Alias="osm-berlin" Name="osm-berlin" Type="MapConfiguration" Child="false" >
				<ChildLayer>forests</ChildLayer>
				<ChildLayer>water_bodies</ChildLayer>
				<ChildLayer>agriculture</ChildLayer>
				<ChildLayer>green_areas</ChildLayer>
				<ChildLayer>buildings</ChildLayer>
				<ChildLayer>religion</ChildLayer>
				<ChildLayer>rivers</ChildLayer>
				<ChildLayer>cemeteries</ChildLayer>
				<ChildLayer>motorway</ChildLayer>
				<ChildLayer>trunk</ChildLayer>
				<ChildLayer>rd_primary</ChildLayer>
				<ChildLayer>rd_secondary</ChildLayer>
				<ChildLayer>rd_tertiary</ChildLayer>
				<ChildLayer>rd_residential</ChildLayer>
				<ChildLayer>paths</ChildLayer>
				<ChildLayer>cycleways</ChildLayer>
				<ChildLayer>subway</ChildLayer>
				<ChildLayer>rail</ChildLayer>
				<ChildLayer>light_rail</ChildLayer>
				<ChildLayer>tram</ChildLayer>
				<ChildLayer>suburbs</ChildLayer>
				<ChildLayer>railway_stations</ChildLayer>
				<ChildLayer>tram_stops</ChildLayer>
			</Layer>
			<Layer Alias="agriculture" Name="agriculture" Type="VectorCoverage" Child="true" />
			<Layer Alias="buildings" Name="buildings" Type="VectorCoverage" Child="true" />
			<Layer Alias="cemeteries" Name="cemeteries" Type="VectorCoverage" Child="true" />
			<Layer Alias="cycleways" Name="cycleways" Type="VectorCoverage" Child="true" />
			<Layer Alias="forests" Name="forests" Type="VectorCoverage" Child="true" />
			<Layer Alias="green_areas" Name="green_areas" Type="VectorCoverage" Child="true" />
			<Layer Alias="light_rail" Name="light_rail" Type="VectorCoverage" Child="true" />
			<Layer Alias="motorway" Name="motorway" Type="VectorCoverage" Child="true" />
			<Layer Alias="paths" Name="paths" Type="VectorCoverage" Child="true" />
			<Layer Alias="rail" Name="rail" Type="VectorCoverage" Child="true" />
			<Layer Alias="railway_stations" Name="railway_stations" Type="VectorCoverage" Child="true" />
			<Layer Alias="rd_primary" Name="rd_primary" Type="VectorCoverage" Child="true" />
			<Layer Alias="rd_residential" Name="rd_residential" Type="VectorCoverage" Child="true" />
			<Layer Alias="rd_secondary" Name="rd_secondary" Type="VectorCoverage" Child="true" />
			<Layer Alias="rd_tertiary" Name="rd_tertiary" Type="VectorCoverage" Child="true" />
			<Layer Alias="religion" Name="religion" Type="VectorCoverage" Child="true" />
			<Layer Alias="rivers" Name="rivers" Type="VectorCoverage" Child="true" />
			<Layer Alias="suburbs" Name="suburbs" Type="VectorCoverage" Child="true" />
			<Layer Alias="subway" Name="subway" Type="VectorCoverage" Child="true" />
			<Layer Alias="tram" Name="tram" Type="VectorCoverage" Child="true" />
			<Layer Alias="tram_stops" Name="tram_stops" Type="VectorCoverage" Child="true" />
			<Layer Alias="trunk" Name="trunk" Type="VectorCoverage" Child="true" />
			<Layer Alias="water_bodies" Name="water_bodies" Type="VectorCoverage" Child="true" />
		</MainDB>
	</WmsLayers>
</WmsLiteConfig>
</verbatim>

</table>

<br><hr><br>
Back to <a Berlin Index</a><br><br>