/*==============================================================================
	MPK
    Mpk.RouteFormat class implementation

    Javascript library
    Require OpenLayers library
    $Id: RouteFormat.js 1233 2008-02-28 11:00:58Z mmanzato $
==============================================================================*/


// Mpk.RouteFormat class
Mpk.RouteFormat = OpenLayers.Class(
    OpenLayers.Format.GML, {

    /**
     * Associated route layer. Used to add marker icons to the route while the
     * GML route is being parsed.
     **/
    routeLayer: null,

    /**
     * Constructor
     */
    initialize: function(options) {
        OpenLayers.Format.GML.prototype.initialize.apply(this, arguments);
        this.routeLayer = options.routeLayer;
    },

    /**
     * Destructor
     */
    destroy: function() {
        OpenLayers.Format.GML.prototype.destroy.apply(this, arguments);
    },
    
    /**
     * Parse feature node and return a geometry.
     * When the feature being parsed is a gml:Point then a Mpk.RouteIcon
     * marker icon is added to the route layer (actually, the marker route
     * layer)
     *
     * @param xmlNode
     */
    parseFeature: function(xmlNode) {
        // Try to create route icon marker
        if (Mpk.RouteIcon.prototype.build(this.routeLayer, xmlNode))
            return null;
        else
            // Defaults to normal behaviour
            return OpenLayers.Format.GML.prototype.parseFeature.apply(this, arguments);
    },

    /** @final @type String */
    CLASS_NAME: "Mpk.RouteFormat"
});

/*==============================================================================
    End of file
==============================================================================*/

