Configuration example

Configuration example

<config xmlns="http://software.in2p3.fr/lavoisier/config.xsd" xmlns:kml="http://www.opengis.net/kml/2.2" version="13">
    <authenticators name="administrator">
        <authenticator type="IPAddressAuthenticator">
            <parameter name="addresses">
                <entry>127.0.0.1</entry>
                <entry>0:0:0:0:0:0:0:1</entry>
            </parameter>
        </authenticator>
    </authenticators>
    <authenticators name="user">
        <authenticator type="HTTPBasicAuthenticator" authorized="user()='lavoisier'">
            <parameter name="passwords" eval="view_path('properties', '/security/passwords.properties')"/>
        </authenticator>
        <authenticator type="IPAddressAuthenticator">
            <parameter name="addresses">
                <entry>127.0.0.1</entry>
                <entry>0:0:0:0:0:0:0:1</entry>
            </parameter>
        </authenticator>
    </authenticators>

    <view name="parking_lyon" authenticators="administrator">
        <info>
            <category>demo</category>
        </info>
        <connector type="HTTPConnector">
            <parameter name="url">https://download.data.grandlyon.com/kml/grandlyon/?request=layer&amp;typename=pvo_patrimoine_voirie.pvoparking</parameter>
        </connector>
        <serializer type="ZipSerializer"/>
        <processors>
            <processor type="InsertProcessor" match="/kml:kml/kml:Document/kml:Placemark/kml:Point/kml:coordinates[text()]">
                <parameter name="nodes" eval="new_attribute('lng', substring-before(text(),',')) | new_attribute('lat', substring-after(text(),','))"/>
            </processor>
        </processors>
        <cache type="FileCache">
            <trigger type="ViewCreatedTrigger" ignore-during="PT1H"/>
            <trigger type="ViewNotifiedTrigger"/>
        </cache>
    </view>

    <view name="parking" authenticators="user">
        <info>
            <category>demo</category>
        </info>
        <argument name="destination"/>
        <argument name="distance">400</argument>
        <variable name="angle" eval="$distance * 360 div 40075000"/>
        <connector type="HTTPConnector">
            <parameter name="url" eval="concat('http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&amp;address=', translate($destination,' ','+'))"/>
        </connector>
        <validator type="PathValidator">
            <parameter name="path">/GeocodeResponse/result</parameter>
            <parameter name="message" eval="concat('Unknown location: ', $destination)"/>
        </validator>
        <processors xmlns:math="http://exslt.org/math">
            <processor type="ElementToAttributeProcessor" match="/GeocodeResponse/result/geometry/location"/>
            <processor type="InsertProcessor" match="/GeocodeResponse/result/geometry/location">
                <parameter name="nodes" eval="view('parking_lyon')"/>
            </processor>
            <processor type="InsertProcessor" match="/GeocodeResponse/result/geometry/location/kml:kml/kml:Document/kml:Placemark/kml:Point/kml:coordinates">
                <parameter name="nodes" eval="new_attribute('Distance', math:sqrt(math:power(ancestor::location/@lat - @lat, 2) + math:power(ancestor::location/@lng - @lng, 2)))"/>
            </processor>
            <processor type="RemoveProcessor" match="/GeocodeResponse/result/geometry/location/kml:kml/kml:Document/kml:Placemark/kml:Point/kml:coordinates[@Distance &gt; $angle]"/>
        </processors>
        <pre-renderers>
            <title>'Parking Coordinates'</title>
            <field>/GeocodeResponse/result/geometry/location/@lat</field>
            <field>/GeocodeResponse/result/geometry/location/@lng</field>
            <row foreach="/GeocodeResponse/result/geometry/location/kml:kml/kml:Document/kml:Placemark/kml:Point/kml:coordinates">
                <column label="Latitude">(round(@lat*100000) div 100000)</column>
                <column label="Longitude">(round(@lng*100000) div 100000)</column>
                <column unit="degrees">@Distance</column>
            </row>
        </pre-renderers>
        <renderers>
            <renderer type="CsvRenderer">
                <parameter name="separator">;</parameter>
            </renderer>
            <renderer type="DefaultRenderer">
                <parameter name="template">demo/parking.html</parameter>
            </renderer>
            <renderer type="HTMLRenderer">
                <parameter name="template">demo/parking.html</parameter>
            </renderer>
            <renderer type="ChartRenderer">
                <parameter name="axis">polar</parameter>
            </renderer>
        </renderers>
    </view>
</config>