Layer Not Showing

13 messages Options
Embed this post
Permalink
ATI

Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Hi,
    i am looking at the MapViewer demo in relation to my project and taking ideas from their into mine, in particular the load function. At present,  the application uses a file->open technique where the user selects the .shp file to use and displays it, which it does successfully. But, in doing so, the app also reads the .sld file where the location has been hard coded into the app and read it. Right now, the app does not show the road names from my .dbf file which is the problem. The function code snippet is as follows:


 public void displayShapeFile(File shpFile, File sldFile)
    {
       StyleFactory factory = CommonFactoryFinder.getStyleFactory(null);

             // Create parser to parse SLD File and a style factory
              SLDParser stylereader = new SLDParser(factory,sldFile);

              // create an array style to read the xml
              org.geotools.styling.Style[] style = stylereader.readXML();

              // add layter for style and features
              mapContext.addLayer(source,style[0]);

            mapPane.repaint();
             // Use this to define the "context" which holds the displayed layers
          // defines contents
           mapPane.setContext(mapContext);
mapPane.setReset(true);

// catc/try statenment ended.

I've been following the demo the best i can, but clearly something is missing. Can somebody  tell me why it is not displaying my road names please. I've given the .sld for referrence.roadText.sld
Ian Turton

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
On Wed, Jun 17, 2009 at 4:45 PM, ATI<[hidden email]> wrote:

>
> Hi,
>    i am looking at the MapViewer demo in relation to my project and taking
> ideas from their into mine, in particular the load function. At present,
> the application uses a file->open technique where the user selects the .shp
> file to use and displays it, which it does successfully. But, in doing so,
> the app also reads the .sld file where the location has been hard coded into
> the app and read it. Right now, the app does not show the road names from my
> .dbf file which is the problem. The function code snippet is as follows:
>

What happens if you try to display your data and sld in the MapViewer?
if that works then we can narrow the problem down to your code, if not
then it looks like your sld file is wrong and we need to investigate
that further.

Give it a try and let us know what happens.

Ian

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Hi,

   i was not able to get the MapViewer demo to show my data, i.e both the .shp file(lines) and the road names did not appear in the demo. But in my own version, the shape file can be seen and not the road names. hope that is clear.

Please note: in the demo i have not added the jai_core, jai_imageio files in my pom because i get errors.
Thanks
Ian Turton wrote:
On Wed, Jun 17, 2009 at 4:45 PM, ATI<luong8201@hotmail.com> wrote:
>
> Hi,
>    i am looking at the MapViewer demo in relation to my project and taking
> ideas from their into mine, in particular the load function. At present,
> the application uses a file->open technique where the user selects the .shp
> file to use and displays it, which it does successfully. But, in doing so,
> the app also reads the .sld file where the location has been hard coded into
> the app and read it. Right now, the app does not show the road names from my
> .dbf file which is the problem. The function code snippet is as follows:
>

What happens if you try to display your data and sld in the MapViewer?
if that works then we can narrow the problem down to your code, if not
then it looks like your sld file is wrong and we need to investigate
that further.

Give it a try and let us know what happens.

Ian

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Hi Luong,

> Please note: in the demo i have not added the jai_core, jai_imageio files in
> my pom because i get errors.

JAI is for working with images,  If you only need to display vector
data you don't need to worry about it.

It sounds like your SLD file might be the culprit.  If you post it to
the list along, with your shapefile attribute names, we might spot the
problem for you.

cheers
Michael

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Hi Michael,

  Yea sure, but before that i also wanted to let you know that whilst i was testing my app with the code i added to deal with the road names and stuff, after displaying my shape file, when i click on the zoom button, the application freezes and does not zoom in. Also, it does not close straight away when i click on X, it takes a bit of time to disappear, so i simply close the program using the task manager.  The same goes for when zoom out/mape movement. When i comment the code out it is fine. This tells me that the code may also need adjusting. Hopes that makes sense

Here are the corresponding .shp files in a .zip folder.
Cavendish_map_data.zip

mbedward wrote:
Hi Luong,

> Please note: in the demo i have not added the jai_core, jai_imageio files in
> my pom because i get errors.

JAI is for working with images,  If you only need to display vector
data you don't need to worry about it.

It sounds like your SLD file might be the culprit.  If you post it to
the list along, with your shapefile attribute names, we might spot the
problem for you.

cheers
Michael

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Hi Luong

I've hacked your SLD file (attached).

I admit to finding SLD confusing myself but this one seems to work for
me with your shapefile.

Michael


------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

map_01_data.sld (4K) Download Attachment
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
OK cool, i'll let you know how things go.
mbedward wrote:
Hi Luong

I've hacked your SLD file (attached).

I admit to finding SLD confusing myself but this one seems to work for
me with your shapefile.

Michael

 
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Hi,
      i've tested out the sld file on my app and noticed that there was a sllight error on sld file that NB pict up, which was that it was not ended with </sld:StyledLayerDescriptor> but instead with </StyledLayerDescriptor> so i just corrected it accordingly.

After making the correction, and loading my .shp file i still noticed that it did not pick up my road names. This makes me think that there is something missing in my code. Is there something very minute that i am missing? I could be wrong in saying this, but do i need to explicitely say somewhere in my program that i needs to pick up my .dbf file?

Thanks
ATI wrote:
OK cool, i'll let you know how things go.
mbedward wrote:
Hi Luong

I've hacked your SLD file (attached).

I admit to finding SLD confusing myself but this one seems to work for
me with your shapefile.

Michael

 
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Or create a another layer for the road names themeselves?

ATI wrote:
Hi,
      i've tested out the sld file on my app and noticed that there was a sllight error on sld file that NB pict up, which was that it was not ended with </sld:StyledLayerDescriptor> but instead with </StyledLayerDescriptor> so i just corrected it accordingly.

After making the correction, and loading my .shp file i still noticed that it did not pick up my road names. This makes me think that there is something missing in my code. Is there something very minute that i am missing? I could be wrong in saying this, but do i need to explicitely say somewhere in my program that i needs to pick up my .dbf file?

Thanks
ATI wrote:
OK cool, i'll let you know how things go.
mbedward wrote:
Hi Luong

I've hacked your SLD file (attached).

I admit to finding SLD confusing myself but this one seems to work for
me with your shapefile.

Michael

 
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
In reply to this post by ATI
Hi Luong,

I just had another look and there was an error in the SLD file (there
are in most of mine !)

Change the value for <sld:FeatureTypeName> from Roads to map_01_data

> missing? I could be wrong in saying this, but do i need to explicitely say
> somewhere in my program that i needs to pick up my .dbf file?

No, as Ian said you should more or less forget about the dbf file.
Just think shapefile.

Michael

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
Oh ok cool, i'll let you know how things go.
mbedward wrote:
Hi Luong,

I just had another look and there was an error in the SLD file (there
are in most of mine !)

Change the value for <sld:FeatureTypeName> from Roads to map_01_data

> missing? I could be wrong in saying this, but do i need to explicitely say
> somewhere in my program that i needs to pick up my .dbf file?

No, as Ian said you should more or less forget about the dbf file.
Just think shapefile.

Michael

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
ATI

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
In reply to this post by mbedward
SUCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Anyway,


I tried the application and noticed that it did not work. So i looked the sld file and noticed that i had a line symbolizer and realised that because i already have it hard coded in  my java app i did see any reason to have that there so i simply removed it. I then, built my app and ran the project and saw my road names in black(color choice is not great so i might change it) in their positions. This made me believe that the linesymbolizer was the culprit and i think when i ran it before it was also trying to render my lines before rendering the text. I also looked at Ians site he suggested to see if there were any errors or inconsistencies, https://www.e-education.psu.edu/geog585/l5_p5.html but found there were known.

I think the problem was also logic aswell.


Thanks both you Ian and Michael for helping me with my app project, it means alot that you took the time to help me.

Cheers
mbedward wrote:
Hi Luong,

I just had another look and there was an error in the SLD file (there
are in most of mine !)

Change the value for <sld:FeatureTypeName> from Roads to map_01_data

> missing? I could be wrong in saying this, but do i need to explicitely say
> somewhere in my program that i needs to pick up my .dbf file?

No, as Ian said you should more or less forget about the dbf file.
Just think shapefile.

Michael

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: Layer Not Showing

Reply Threaded More More options
Print post
Permalink
> SUCESS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I like the sound of that :)

Michael

------------------------------------------------------------------------------
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users