Probem on OpenLayers WFS

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Probem on OpenLayers WFS

Alextave

Hi everybody, I am new in Openlayers world. I am writing my thesis in computer science about geospatial database.

I want use a OpenLayers WFS that refers to this WFS (made using deegree) http://localhost:8080/services/WFSgeoDB.

This is what I wrote in my JSP:

 

var map = new OpenLayers.Map('map');

 

var WFSgeoDB=new OpenLayers.Layer.Vector("WFS", {

strategies: [new OpenLayers.Strategy.BBOX()],

protocol: new OpenLayers.Protocol.WFS({

version: "1.0.0",

url: "http://localhost:8080/services/WFSgeoDB",

featureType: "app:points",

})

});

var wms = new OpenLayers.Layer.WMS (

"OpenLayers WMS",

"http://vmap0.tiles.osgeo.org/wms/vmap0",

{layers: 'basic'}

);

map.addLayers([wms, WFSgeoDB]);

map.zoomToMaxExtent();

 

I can see the map but I can't see the data from my WFS (7 LineString and 7 Points from my database).

Where is my error? Is there something that I miss to view the data from my db? I need help.

 

Thanks so much

Andrea

 


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Bart van den Eijnden
<base href="x-msg://12/">featureType should be without the prefix so just "points".

Depending on the OpenLayers version that you use you might need to set featureNS (not needed for 2.13 or later, maybe even 2.12 has the automatic detection, unsure).

Use something like Firebug / Chrome web inspector to track your XHR response.

Best regards,
Bart

-- 
Bart van den Eijnden
OpenGeo - http://opengeo.org
Expert service straight from the developers.



On Aug 15, 2013, at 3:30 PM, [hidden email] wrote:

Hi everybody, I am new in Openlayers world. I am writing my thesis in computer science about geospatial database.
I want use a OpenLayers WFS that refers to this WFS (made using deegree) http://localhost:8080/services/WFSgeoDB.
This is what I wrote in my JSP:

 

var map = new OpenLayers.Map('map');

 

var WFSgeoDB=new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.WFS({
version: "1.0.0",
featureType: "app:points",
})
});

var wms = new OpenLayers.Layer.WMS (
"OpenLayers WMS",
{layers: 'basic'}
);

map.addLayers([wms, WFSgeoDB]);
map.zoomToMaxExtent();

 

I can see the map but I can't see the data from my WFS (7 LineString and 7 Points from my database).
Where is my error? Is there something that I miss to view the data from my db? I need help.

 

Thanks so much
Andrea

 

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Phil Scadden
And check that your proxy is working. (so that browser doesnt block XHR)

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
I am pretty sure that this works:

  var map = new OpenLayers.Map('map');

  var wms = new OpenLayers.Layer.WMS (
    "OpenLayers WMS",
    "http://vmap0.tiles.osgeo.org/wms/vmap0",
    {layers: 'basic'}
  );

  var WFSgeoDB=new OpenLayers.Layer.Vector("WFS", {
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: new OpenLayers.Protocol.WFS.v1_1_0({
      url: "http://localhost:8080/services/WFSgeoDB",
      featureType: "streets",
      featureNS: "http://www.deegree.org/app",
      featurePrefix: "app",
      geometryName: "road"
    })
  });
 
  map.addLayers([wms, WFSgeoDB]);
  map.zoomToMaxExtent();

I was so stupid, I forgot geometryName and featureNS.

Thanks so much for the help
Andrea
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
Unfortunatly I am stuck again, I obtained this wfs:FeatureCollection using the previous WFS:

<?xml version='1.0' encoding='UTF-8'?>
<wfs:FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:wfs="http://www.opengis.net/wfs" timeStamp="2013-08-21T08:40:39Z" xmlns:gml="http://www.opengis.net/gml">
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada1">
      <app:nome_S>Strada1</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada1_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.487848 0.000631 -127.487669 0.000631</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada2">
      <app:nome_S>Strada2</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada2_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.488162 0.000388 -127.487964 0.000289</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada3">
      <app:nome_S>Strada3</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada3_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.487848 0.000902 -127.488027 0.000388</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada4">
      <app:nome_S>Strada4</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada4_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.487857 0.000586 -127.488359 0.000289</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada5">
      <app:nome_S>Strada5</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada5_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.488341 0.000586 -127.488457 0.000388</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada6">
      <app:nome_S>Strada6</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada6_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.487938 0.000388 -127.488430 0.000316</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
  <gml:featureMember>
    <app:streets xmlns:app="http://www.deegree.org/app" gml:id="APP_STREETS_Strada7">
      <app:nome_S>Strada7</app:nome_S>
      <app:road>
       
        <gml:LineString gml:id="APP_STREETS_Strada7_APP_ROAD" srsName="EPSG:4326">
          <gml:posList>-127.488144 0.000604 -127.488027 0.000722</gml:posList>
        </gml:LineString>
      </app:road>
    </app:streets>
  </gml:featureMember>
</wfs:FeatureCollection>

Using OpenLayers how can I retrieve those feature Members?

Thanks again
Andrea
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Phil Scadden
That looks like valid GML. Openlayers should construct a layer object
from it. Breakpoint after the map.addLayers and look at the
WFSgeoDB.features object to see that data has loaded properly. You would
normally access the feature members in the context of an event handler.

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
This statement
console.log(WFSgeoDBPunti.features);

prints this in the console:
[ ]

It is not right, you said "You would normally access the feature members in the context of an event handler", what do you mean?
I don't know how to use an event handler beacause I am new in OpenLayers.

Best regards
Andrea
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Phil Scadden

> This statement
> console.log(WFSgeoDBPunti.features);
>
> prints this in the console:
> [ ]
Hmm. This implies features not sent or they are malformed and not parsed
correctly. By way, I strongly recommend that you get used to the
debugging with firebug or chrome tools. Makes investigating this much
easier and you will learn a lot about OL in the process.
On the Net tab of either tool, you will see the POST request that
fetches the features. Look at the response.  Is this the GML features
that you posted earlier? Looks valid GML, except that you are requesting
lineStrings, but I only see one point in each feature? Wonder if that is
set up properly at the server end?
> I don't know how to use an event handler beacause I am new in OpenLayers.
Well normally you would be wanting to access features in response to
something that a user does (eg click on the feature - though if you are
using WFS instead of WMS, perhaps you want hover?). This is usually
managed in OL by controls of various sorts, each of which have events
associated with them. You register a handler for the event and you get
the features in context.
eg
http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/feature-events.html


Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
Hi again, I'm stuck again I managed to view the data on the map but, after some changes, the data are no longer displayed and the feature object in the WFS is empty again.
This is my code in this moment:

  var Parametri_WFSPunti=new Object();
  Parametri_WFSPunti.url="http://localhost:8080/services/WFSgeoDB";
  Parametri_WFSPunti.featureType="Punto";
  Parametri_WFSPunti.featureNS="http://www.deegree.org/app";
  Parametri_WFSPunti.featurePrefix="app";
  Parametri_WFSPunti.geometryName="Point";
  Parametri_WFSPunti.outputFormat="GML2";
 
  var Parametri_WFSTratti=new Object();
  Parametri_WFSTratti.url="http://localhost:8080/services/WFSgeoDB";
  Parametri_WFSTratti.featureType="Tratto";
  Parametri_WFSTratti.featureNS="http://www.deegree.org/app";
  Parametri_WFSTratti.featurePrefix="app";
  Parametri_WFSTratti.geometryName="Percorso";
  Parametri_WFSTratti.outputFormat="GML2";
 
  var WFSPunti=new OpenLayers.Protocol.WFS.v1_1_0(Parametri_WFSPunti);
  var WFSTratti=new OpenLayers.Protocol.WFS.v1_1_0(Parametri_WFSTratti);
 
  var WFSgeoDBPunti=new OpenLayers.Layer.Vector("WFSP", {
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: WFSPunti
  });
 
  var WFSgeoDBTratti=new OpenLayers.Layer.Vector("WFST", {
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: WFSTratti
  });

Surfing the web I found some information about this property of OpenLayers.Layer.Vector
 eventListeners: {
    "featuresadded": Dati
 }

The argument Dati must be a function but how should be written this function? Can this property be useful to load e fetch the data from my featureCollection?
Otherwise what can I do?
Please help me I am in trouble

Andrea
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
Another thing, still surfing the web I found some information about ProxyHost object the can be use to load/fetch data from/to WFS.
Since my WFS is server-side and  openlayers is on client-side, do I need a ProxyHost object?
How can I write/use it?

Best regards
Andrea
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Jerome A. Wendell

The information at the link below should answer your questions concerning a ProxyHost:

 

http://trac.osgeo.org/openlayers/wiki/FrequentlyAskedQuestions#ProxyHost

 

 

 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Alextave
Sent: Friday, September 13, 2013 12:15 PM
To: [hidden email]
Subject: Re: [OpenLayers-Users] Probem on OpenLayers WFS

 

Another thing, still surfing the web I found some information about ProxyHost object the can be use to load/fetch data from/to WFS.

Since my WFS is server-side and  openlayers is on client-side, do I need a ProxyHost object?

How can I write/use it?

 

Best regards

Andrea

 

 

 

--

View this message in context: http://osgeo-org.1560.x6.nabble.com/Probem-on-OpenLayers-WFS-tp5072697p5077738.html

Sent from the OpenLayers Users mailing list archive at Nabble.com.

_______________________________________________

Users mailing list

[hidden email]

http://lists.osgeo.org/mailman/listinfo/openlayers-users


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
The proxy that it is adviced is good eough or it needs some modifications?
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Jerome A. Wendell
You would add your domain to the allowedHosts section of the proxy file.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Alextave
Sent: Friday, September 13, 2013 12:56 PM
To: [hidden email]
Subject: Re: [OpenLayers-Users] Probem on OpenLayers WFS

The proxy that it is adviced is good eough or it needs some modifications?



--
View this message in context:
http://osgeo-org.1560.x6.nabble.com/Probem-on-OpenLayers-WFS-tp5072697p50777
44.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Laura Kauria
Good luck with the Proxy problem. I had to to fight with it for over two weeks so I really hope you get it faster correct on your server! The instructions about needing and building up a proxy host aren't that clear at the moment.

I could easily manage to copy-paste the proxy.php to my server, but adding the right domains and ports weren't anymore that casual. After adding the proxy.php I had to do some changes on server management that my webserver actually reads the .php file.

Laura





2013/9/13 Jerome A. Wendell <[hidden email]>
You would add your domain to the allowedHosts section of the proxy file.


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Alextave
Sent: Friday, September 13, 2013 12:56 PM
To: [hidden email]
Subject: Re: [OpenLayers-Users] Probem on OpenLayers WFS

The proxy that it is adviced is good eough or it needs some modifications?



--
View this message in context:
<a href="http://osgeo-org.1560.x6.nabble.com/Probem-on-OpenLayers-WFS-tp5072697p50777 44.html" target="_blank">http://osgeo-org.1560.x6.nabble.com/Probem-on-OpenLayers-WFS-tp5072697p50777
44.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Phil Scadden
The problems with proxyhost, is that everyone's server side is different
and generally you really need to think about what your proxy will and
will not do within the security requirements of your application. You
certainly dont want to inadvertently create an open proxy. The examples
point to generic cgi, php, or jsp scripts but there are also .py
versions. If you dont work server-side much and dont understand this
issues, then I would strongly suggest you get some help from the server
people in your team.

But to original query - yes you absolutely need to get proxyhost sorted
to do anything more complicated than WMS.


Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Probem on OpenLayers WFS

Alextave
Hi everybody, please forgive my late reply. After some hard work on my code I decided to use event handler and not te proxy because the proxy is too complicated for no reason (in my opinion).

This is my code and works really nice:
     var Parametri_WFSMuraN=new Object();
      Parametri_WFSMuraN.url="http://localhost:8080/services/WFSbabDB";
      Parametri_WFSMuraN.featureType="MuraN";
      Parametri_WFSMuraN.featureNS="http://www.deegree.org/app";
      Parametri_WFSMuraN.featurePrefix="app";
      Parametri_WFSMuraN.geometryName="Forma";
      Parametri_WFSMuraN.outputFormat="GML2";
      var WFSMuraN=new OpenLayers.Protocol.WFS.v1_1_0(Parametri_WFSMuraN);
     
      var LayerWFSMuraN=new OpenLayers.Layer.Vector("WFSMUN", {
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: WFSMuraN
      });
     
      var GetFeatureMuraN=new OpenLayers.Control.GetFeature({
        protocol: WFSMuraN,
        click: true
      });
      GetFeatureMuraN.events.register("featureselected", this, function(e) {
        LayerWFSMuraN.addFeatures([e.feature]);
        var nome=e.feature.data.Nome_MU;
        var desc=e.feature.data.Descrizione;
 
        doc2.innerHTML="Nome: "+nome+"</br>"+"Descrizione: "+desc+"</br>";
      });

      map.addControl(GetFeatureMuraN);
      GetFeatureMuraN.activate();
      map.addLayer(LayerWFSMuraN);

Thankyou so much for the help
Best regards Andrea