[Commits] r2530 - in sandbox/cmoullet/ux: . Profile Profile/examples Profile/lib Profile/lib/GeoExt.ux

commits at geoext.org commits at geoext.org
Fri Dec 24 08:36:04 CET 2010


Author: cmoullet
Date: 2010-12-24 08:36:04 +0100 (Fri, 24 Dec 2010)
New Revision: 2530

Added:
   sandbox/cmoullet/ux/Profile/
   sandbox/cmoullet/ux/Profile/examples/
   sandbox/cmoullet/ux/Profile/examples/profile.html
   sandbox/cmoullet/ux/Profile/examples/profile.js
   sandbox/cmoullet/ux/Profile/lib/
   sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/
   sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileAction.js
   sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileControl.js
   sandbox/cmoullet/ux/Profile/tests/
Log:
Initial structure of a GeoExt.ux Profile

Added: sandbox/cmoullet/ux/Profile/examples/profile.html
===================================================================
--- sandbox/cmoullet/ux/Profile/examples/profile.html	                        (rev 0)
+++ sandbox/cmoullet/ux/Profile/examples/profile.html	2010-12-24 07:36:04 UTC (rev 2530)
@@ -0,0 +1,30 @@
+<html>
+<head>
+    <title>Profile Action Example</title>
+
+    <script type="text/javascript" src="../../../trunk/ext/adapter/ext/ext-base.js"></script>
+    <script type="text/javascript" src="../../../trunk/ext/ext-all.js"></script>
+    <link rel="stylesheet" type="text/css" href="../../../trunk/ext/resources/css/ext-all.css"/>
+    <link rel="stylesheet" type="text/css" href="../../../trunk/ext/examples/shared/examples.css"/>
+    <script type="text/javascript" src="../../../trunk/openlayers/lib/OpenLayers.js"></script>
+    <script type="text/javascript" src="../../../trunk/geoext/lib/GeoExt.js"></script>
+    <script type="text/javascript" src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js"></script>
+    <script type="text/javascript" src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/defs/EPSG900913.js"></script>
+    <script type="text/javascript" src="http://svn.osgeo.org/metacrs/proj4js/trunk/lib/defs/EPSG21781.js"></script>
+
+    <!-- script resources for this ux -->
+    <script type="text/javascript" src="../lib/GeoExt.ux/ProfileControl.js"></script>
+    <script type="text/javascript" src="../lib/GeoExt.ux/ProfileAction.js"></script>
+
+    <script type="text/javascript" src="profile.js"></script>
+</head>
+<body>
+<h1>Toolbar with Profile action</h1>
+
+<p style="margin-bottom:15px;">This example shows how to use the GeoExt.ux.Profile action in a toolbar</p>
+
+<p style="margin-bottom:15px;">See <a href="profile.js">profile.js</a> for the source code.</p>
+
+<div id="mapppanel"></div>
+</body>
+</html>
\ No newline at end of file

Added: sandbox/cmoullet/ux/Profile/examples/profile.js
===================================================================
--- sandbox/cmoullet/ux/Profile/examples/profile.js	                        (rev 0)
+++ sandbox/cmoullet/ux/Profile/examples/profile.js	2010-12-24 07:36:04 UTC (rev 2530)
@@ -0,0 +1,29 @@
+Ext.onReady(function() {
+
+    // required for tooltips
+    Ext.QuickTips.init();
+
+    var map = new OpenLayers.Map();
+
+    var vector = new OpenLayers.Layer.Vector("Profile Line Layer", {displayInLayerSwitcher: false});
+
+    var profileAction = new GeoExt.ux.Profile({
+        map: map,
+        text: OpenLayers.i18n('Profile'),
+        vector: vector, 
+        profileService: 'api.geo.admin.ch'
+    });
+
+    var mapPanel = new GeoExt.MapPanel({
+        renderTo: "mapppanel",
+        width: 800,
+        height: 350,
+        map: map,
+        layers: [new OpenLayers.Layer.WMS("Global Imagery",
+            "http://vmap0.tiles.osgeo.org/wms/vmap0",
+            {layers: "basic"}), vector],
+        center: [7.5, 47],
+        zoom: 8,
+        tbar: [profileAction]
+    });
+});
\ No newline at end of file

Added: sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileAction.js
===================================================================
--- sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileAction.js	                        (rev 0)
+++ sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileAction.js	2010-12-24 07:36:04 UTC (rev 2530)
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ *
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+Ext.namespace("GeoExt.ux");
+
+/*
+ * @requires GeoExt/widgets/Action.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux
+ *  class = Profile
+ */
+
+/** api: constructor
+ *  .. class:: Profile(config)
+ *
+ *      Creates a GeoExt.Action for profile.
+ *
+ */
+GeoExt.ux.Profile = Ext.extend(Ext.Action, {
+
+    /** api: config[profileService]
+     *  ``String`` Name of the profile service. Optional.
+     */
+
+    /** private: method[constructor]
+     */
+    constructor: function(config) {
+        var drawControl = new OpenLayers.Control.ProfileControl(
+                config.vector, OpenLayers.Handler.Path
+                );
+
+        drawControl.events.register('featureadded', this, function(event) {
+            this.createProfile(event);
+        });
+
+        this.profileService = config.profileService;
+        this.map = config.map;
+
+        config.map.addControl(drawControl);
+
+        config = Ext.apply({
+            allowDepress: false,
+            text: OpenLayers.i18n('Profile'),
+            handler: function() {
+                if (!drawControl.active) {
+                    drawControl.activate();
+                } else {
+                    drawControl.cleanFeature();
+                }
+            }
+        }, config);
+
+        GeoExt.ux.Profile.superclass.constructor.call(this, config);
+    },
+
+    createProfile: function(event) {
+        if (this.profileService == 'api.geo.admin.ch') {
+            var formatter = new OpenLayers.Format.GeoJSON({internalProjection: this.map.getProjectionObject(),
+                externalProjection: new OpenLayers.Projection("EPSG:21781")});
+            var geometryGeoJSON = formatter.write(event.feature.geometry);
+        }
+    }
+});

Added: sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileControl.js
===================================================================
--- sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileControl.js	                        (rev 0)
+++ sandbox/cmoullet/ux/Profile/lib/GeoExt.ux/ProfileControl.js	2010-12-24 07:36:04 UTC (rev 2530)
@@ -0,0 +1,26 @@
+OpenLayers.Control.ProfileControl = OpenLayers.Class(OpenLayers.Control.DrawFeature, {
+
+    digitizedFeature: null,
+
+    initialize: function(layer, handler, options) {
+        OpenLayers.Control.DrawFeature.prototype.initialize.apply(this, [layer, handler, options]);
+    },
+
+    featureAdded: function(feature) {
+        this.digitizedFeature = feature;
+        this.deactivate();
+    },
+
+    activate: function () {
+        this.cleanFeature();
+        OpenLayers.Control.DrawFeature.prototype.activate.apply(this);
+    },
+    deactivate: function () {
+        OpenLayers.Control.DrawFeature.prototype.deactivate.apply(this);
+    },
+    cleanFeature: function() {
+        if (this.digitizedFeature) {
+            this.digitizedFeature.destroy();
+        }
+    }
+});
\ No newline at end of file



More information about the Commits mailing list