IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

IGN API Géoportail Discussion :

Utilisation de la LayerToolbar


Sujet :

IGN API Géoportail

  1. #1
    Nouveau membre du Club
    Inscrit en
    Mai 2010
    Messages
    73
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 73
    Points : 33
    Points
    33
    Par défaut Utilisation de la LayerToolbar
    Bonjour à tous,

    J'essaie aujourd'hui d'uiliser le control : Geoportal.Control.LayerToolbar

    L'objectif étant de permettre l'ajout de couches WFS provenant d'un Geoserver 2.0.1

    Lorsque dans la boite de dialogue d'ajout de couches vectorielles je choisis "Ressource WFS" et que je rentre l'adresse de mon serveur : "http://x.x.x.x:8080/geoserver/wfs" j'obtiens bien la liste des couches présentes sur mon serveur, jusque là tout va bien !

    Je choisis celle que je veux et elle apparaît bien dans la liste des couches malheureusement les données ne s'affiche pas sur la carte...

    En regardant les requêtes WFS envoyées au serveur je me suis apparçus qu'ils manquait des informations ...

    Exemple de requêtes suite à l'ajout d'une couche via la LayerToolbar :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <wfs:Query typeName="NONE">
    <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
    <ogc:BBOX>
    <ogc:PropertyName>the_geom</ogc:PropertyName>
    <gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:2154">
    <gml:coordinates decimal="." cs="," ts=" ">374283.97291327966,6389295.316558203 437865.2660470217,6403795.308549101</gml:coordinates>
    </gml:Box>
    </ogc:BBOX>
    </ogc:Filter>
    </wfs:Query>
    </wfs:GetFeature>
    On se rend compte que sur la ligne "<wfs:Query typeName="NONE">" il n'y a ni information du serveur ni de la couche voulue... Forcement ce n'est pas mon serveur qui répond ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?xml version="1.0" ?>
    <ServiceExceptionReport
       version="1.2.0"
       xmlns="http://www.opengis.net/ogc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
       <ServiceException>
          Could not locate {http://www.opengis.net/wfs}NONE in catalog.
    </ServiceException></ServiceExceptionReport>
    Cela peut-il venir de mon code ou est-ce un pb connu dans la LayerToolbar ?

    Merci d'avance ...

  2. #2
    Expert confirmé
    Homme Profil pro
    Ingénieur cartographe
    Inscrit en
    Avril 2009
    Messages
    3 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur cartographe
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2009
    Messages : 3 173
    Points : 4 224
    Points
    4 224
    Par défaut
    Citation Envoyé par Sigmax Voir le message
    Cela peut-il venir de mon code ou est-ce un pb connu dans la LayerToolbar ?
    Cela ressemble à un bug. Peux-tu tester cette surcharge

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    Geoportal.Control.AddVectorLayer.prototype.onFeatureTypeNameClick= function(evt) {
            if (!evt) evt= window.event;
            OpenLayers.Event.stop(evt);
            this.cntrl.wImg.style.display= '';
            var f= this.caps.featureTypeList.featureTypes[this.featureTypeIndex];
            var params= {
                'version':this.caps.version,
                'typename': f.name
            };
            var x= null;
            if (f.bbox.length>0) {
                x= new OpenLayers.Bounds();
                for (var j= 0, lbbox= f.bbox.length; j<lbbox; j++) {
                    x.extend(OpenLayers.Bounds.fromArray(f.bbox[j]));
                }
                var p= new OpenLayers.Projection(f.srs);
                x.transform(OpenLayers.Projection.CRS84, p);
            }
            var options= {
                projection: f.srs,
                maxExtent: x,
                visibility: true
            };
            var cn= 'OpenLayers.Layer.WFS';
            switch (this.serviceType) {
            case 'WFS' :
                break;
            default    :
                break;
            }
            if (f['abstract']) {
                options.description= f['abstract'];
            }
            options.originators= [{
                logo:'logo'+f.name,
                pictureUrl: Geoportal.Util.getImagesLocation()+'logo_unknownAuthority.gif',
                url: (f.href? f.href : 'javascript:void(0)')
            }];
            if (f.metadataURLs && f.metadataURLs.length>0) {
                options.metadataURL= [];
                for (var j= 0, lj= f.metadataURLs.length; j<lj; j++) {
                    options.metadataURL.push(f.metadataURLs[j].href);
                }
            }
            this.cntrl.wImg.style.display= 'none';
    
            var href= null;
            switch (this.caps.version) {
            case '1.0.0':
            case '1.1.0':
                href= (this.caps.capability.operations.GetFeature.post && this.caps.capability.operations.GetFeature.post.href) ||
                      (this.caps.capability.operations.GetFeature.get  && this.caps.capability.operations.GetFeature.get.href);
                break;
            default     :
                break;
            }
            var vlayer= this.cntrl.map.addLayer(
                this.serviceType,
                f.title || this.name,
                href,
                params,
                OpenLayers.Util.extend(options,this.cntrl.layerVectorOptions[cn])//FIXME
            );
    
            this.cntrl.closeForm();
        };
    J'avais mis VERSION et TYPENAME (en majuscules)

  3. #3
    Nouveau membre du Club
    Inscrit en
    Mai 2010
    Messages
    73
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 73
    Points : 33
    Points
    33
    Par défaut
    Effectivement c'est mieux ^^
    J'vois pas encore mes données mais j'ai bien une requête qui pars sur mon serveur

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <?xml version="1.0" encoding="UTF-8"?>
    <ows:ExceptionReport version="1.0.0"
      xsi:schemaLocation="http://www.opengis.net/ows http://x.x.x.x:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows">
      <ows:Exception exceptionCode="InvalidParameterValue">
        <ows:ExceptionText>Illegal property name: the_geom</ows:ExceptionText>
      </ows:Exception>
    </ows:ExceptionReport>
    Dans ma couche le champ de géométrie c'est "geom" et pas "the_geom"...

  4. #4
    Expert confirmé
    Homme Profil pro
    Ingénieur cartographe
    Inscrit en
    Avril 2009
    Messages
    3 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur cartographe
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2009
    Messages : 3 173
    Points : 4 224
    Points
    4 224
    Par défaut
    Citation Envoyé par Sigmax Voir le message
    J'vois pas encore mes données mais j'ai bien une requête qui pars sur mon serveurDans ma couche le champ de géométrie c'est "geom" et pas "the_geom"...
    Tu dois utiliser :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    ...
    protocolOptions:{
        geometryName:'geom'
    }
    ...
    dans l'option layerVectorOptions :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    ...
    layerVectorOptions:{
        'OpenLayers.Layer.WFS':{
            protocolOptions:{...}
            ...
         }
    }
    ...
    les autres options utiles sont :
    * featurePrefix
    * featureNS

    Voir la documentation d' OpenLayers.Protocol.WFS

  5. #5
    Nouveau membre du Club
    Inscrit en
    Mai 2010
    Messages
    73
    Détails du profil
    Informations forums :
    Inscription : Mai 2010
    Messages : 73
    Points : 33
    Points
    33
    Par défaut
    Ça marche presque !
    La requête s'exécute bien, je vois qu'il y a des objets dans la réponse ... mais ils ne se dessinent pas sur la carte...

    J'ai pensé à un pb de style... j'ai donc rajouté une partie pour le WFS dans le code exemple pour ajouter la toolbar :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    // add "Layer Toolbar"
            var addLbar= new Geoportal.Control.LayerToolbar(
                {
                    div: OpenLayers.Util.getElement(tbx.id+'_addlyr'),
                    // Geoportal.Control.AddVectorLayer options :
                    addVectorLayerOptions: {
                        supportedClasses: [
                            /*'OpenLayers.Format.KML',
                            'Geoportal.Format.GPX',
                            'OpenLayers.Format.OSM',
                            'OpenLayers.Layer.GeoRSS',*/
                            'OpenLayers.Layer.WFS'
                        ],
                        // OpenLayers.Layer.Vector options :
                        styleMapTemplates: {
    						"OpenLayers.Format.WFS"         :
                                new OpenLayers.StyleMap({
                                    "default"   : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 2,
                                                    pointRadius:  8},
                                                    OpenLayers.Feature.Vector.style["default"])),
                                    "select"    : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 4,
                                                    pointRadius: 12},
                                                    OpenLayers.Feature.Vector.style["select"])),
                                    "temporary" : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF"},
                                                    OpenLayers.Feature.Vector.style["temporary"]))},
                                    {extendDefault:false}),
                            /*"OpenLayers.Format.KML"         :
                                new OpenLayers.StyleMap({
                                    "default"   : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 2,
                                                    pointRadius:  8},
                                                    OpenLayers.Feature.Vector.style["default"])),
                                    "select"    : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 4,
                                                    pointRadius: 12},
                                                    OpenLayers.Feature.Vector.style["select"])),
                                    "temporary" : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF"},
                                                    OpenLayers.Feature.Vector.style["temporary"]))},
                                    {extendDefault:false}),
                            "Geoportal.Format.GPX"          :
                                new OpenLayers.StyleMap({
                                    "default"   : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 2,
                                                    pointRadius:  8},
                                                    OpenLayers.Feature.Vector.style["default"])),
                                    "select"    : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 4,
                                                    pointRadius: 12},
                                                    OpenLayers.Feature.Vector.style["select"])),
                                    "temporary" : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF"},
                                                    OpenLayers.Feature.Vector.style["temporary"]))},
                                    {extendDefault:false}),
                            "OpenLayers.Format.OSM"          :
                                new OpenLayers.StyleMap({
                                    "default"   : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 2,
                                                    pointRadius:  8},
                                                    OpenLayers.Feature.Vector.style["default"])),
                                    "select"    : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF",
                                                    strokeWidth: 4,
                                                    pointRadius: 12},
                                                    OpenLayers.Feature.Vector.style["select"])),
                                    "temporary" : new OpenLayers.Style(OpenLayers.Util.applyDefaults({
                                                    fillColor: "#99CCFF",
                                                    strokeColor: "#99CCFF"},
                                                    OpenLayers.Feature.Vector.style["temporary"]))},
                                    {extendDefault:false}),
                            "OpenLayers.Layer.GeoRSS"        :
                                new OpenLayers.StyleMap(
                                    new OpenLayers.Style(
                                        OpenLayers.Util.applyDefaults({
                                            'graphic': true,
                                            'externalGraphic': Geoportal.Util.getImagesLocation()+"xy-target.gif",
                                            'graphicOpacity': 1.0,
                                            'graphicWidth': 25,
                                            'graphicHeight': 25,
                                            'graphicXOffset': -12.5,
                                            'graphicYOffset': -12.5
                                        },OpenLayers.Feature.Vector.style["default"])))*/
                        },
                        layerVectorOptions: {
    						'OpenLayers.Layer.WFS':{
    							protocolOptions:{
    								version: "1.0.0",
    								srsName: "EPSG:4326",
    								url: "http://192.168.3.85:8080/geoserver/wfs",
    								featureNS :  "http://192.168.3.85:8080/postgis",
    								//featureType: "v_psg_2154",
    								featurePrefix:'postgis',
    								geometryName: "geom",
    								formatOptions:{
    									internalProjection: VISU.getMap().getProjection().clone(),
    									externalProjection: new OpenLayers.Projection('EPSG:2154')
    								}
    							}
    						}
                        }
                    },
                    addImageLayerOptions: { // Force Image Layer button when empty!
                        layerImageOptions: {
                            singleTile:false
                        }
                    }
                }
            );
    Mais ça ne donne tjs rien...
    Si je regarde les coordonnées données dans la réponse du serveur elle sont bien dans l'emprise de la vue pourtant...

  6. #6
    Expert confirmé
    Homme Profil pro
    Ingénieur cartographe
    Inscrit en
    Avril 2009
    Messages
    3 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Ingénieur cartographe
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2009
    Messages : 3 173
    Points : 4 224
    Points
    4 224
    Par défaut
    Citation Envoyé par Sigmax Voir le message
    Mais ça ne donne tjs rien...
    Si je regarde les coordonnées données dans la réponse du serveur elle sont bien dans l'emprise de la vue pourtant...
    Et on peut voir la réponse WFS

Discussions similaires

  1. utiliser les tag [MFC] [Win32] [.NET] [C++/CLI]
    Par hiko-seijuro dans le forum Visual C++
    Réponses: 8
    Dernier message: 08/06/2005, 15h57
  2. Réponses: 4
    Dernier message: 05/06/2002, 14h35
  3. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36
  4. [BCB5] Utilisation des Ressources (.res)
    Par Vince78 dans le forum C++Builder
    Réponses: 2
    Dernier message: 04/04/2002, 16h01
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo