Creating a scalebar to display distance

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

Creating a scalebar to display distance

todd runstein
I'm trying to create something similar to the
"scalebar" found in MapServer.  I'm using brute force
to modify the image generated in the produceMap method
in
org.vfny.geoserver.wms.responses.DefaultRasterMapProducer,
but am having trouble getting a valid measurement.  

Here's the code I'm using (starting at around line
260):

if (map==null ||
map.getCoordinateReferenceSystem()==null){
   System.out.println("Could not create a
measurement");
}else{
   DefaultEllipsoid e = (DefaultEllipsoid)
CRSUtilities.getHeadGeoEllipsoid(map.getCoordinateReferenceSystem());
    Unit unit = e.getAxisUnit();
    Unit target = SI.METER;
    Converter c = unit.getConverterTo(target);
    double d =
c.convert(map.getAreaOfInterest().getWidth());
               
    graphic.setColor(Color.BLACK);
    if (paintArea.width>200) {
      graphic.drawString("Distance may be " +
d,0,paintArea.height);
    }
}

When the map first loads (using MapBuilder), it tells
me that the AreaOfInterest is approximately 1.09
meters, however it's showing all of Multnomah County,
Oregon (not sure what the total width is, but it's
certainly larger than what is shown).  Zooming in
changes the distance displayed in (what appears to be)
the correct proportion, though it is still woefully
short.

I'm using Tiger data (obtained through a ShapeFile)
loaded into Postgis with shp2pgsql and am using
EPSG:4326.  I assume the Ellipsoid I'm retrieving
isn't really what I want, or the
getAreaOfInterest().getWidth() isn't returning
anything that can be reliably converted.  Then again,
maybe it's something else entirely.

Any help would be greatly appreciated!

Todd


The only "dumb question" is the one you were too afraid to ask.
________________________________________
Check out RouteRuler - Free software for runners, cyclists, walkers, etc.
http://routeruler.sourceforge.net
________________________________________
Get a handle on your data with "pocOLAP", the "little" OLAP project
http://pocolap.sourceforge.net
________________________________________


       
               
__________________________________
Yahoo! for Good - Make a difference this year.
http://brand.yahoo.com/cybergivingweek2005/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Creating a scalebar to display distance

Chris Holmes-2
I would love to get a scalebar in GeoServer, if you get this working
please do contribute the code back, just make a bug report and attach
the code you wrote to the issue.  We can probably figure out how to
make a UI so it's easier for others to set.

As for the code, I personally have little idea, but our udig compatriots
have a working scalebar, so in true open source fashion I'd just take a
gander at what they did.  Jody gave this link:
http://svn.geotools.org/udig/trunk/plugins/net.refractions.udig.printing.ui/src/net/refractions/udig/printing/ui/ScalebarMapGraphic.java
which looks like it might contain what you need.  If you have further
questions on how it works just ask the udig list, and I'm sure they'll
help you out.  The gt2 list may also be helpful.

best regards,

Chris

Quoting todd runstein <[hidden email]>:

> I'm trying to create something similar to the
> "scalebar" found in MapServer.  I'm using brute force
> to modify the image generated in the produceMap method
> in
> org.vfny.geoserver.wms.responses.DefaultRasterMapProducer,
> but am having trouble getting a valid measurement.
>
> Here's the code I'm using (starting at around line
> 260):
>
> if (map==null ||
> map.getCoordinateReferenceSystem()==null){
>    System.out.println("Could not create a
> measurement");
> }else{
>    DefaultEllipsoid e = (DefaultEllipsoid)
> CRSUtilities.getHeadGeoEllipsoid(map.getCoordinateReferenceSystem());
>     Unit unit = e.getAxisUnit();
>     Unit target = SI.METER;
>     Converter c = unit.getConverterTo(target);
>     double d =
> c.convert(map.getAreaOfInterest().getWidth());
>
>     graphic.setColor(Color.BLACK);
>     if (paintArea.width>200) {
>       graphic.drawString("Distance may be " +
> d,0,paintArea.height);
>     }
> }
>
> When the map first loads (using MapBuilder), it tells
> me that the AreaOfInterest is approximately 1.09
> meters, however it's showing all of Multnomah County,
> Oregon (not sure what the total width is, but it's
> certainly larger than what is shown).  Zooming in
> changes the distance displayed in (what appears to be)
> the correct proportion, though it is still woefully
> short.
>
> I'm using Tiger data (obtained through a ShapeFile)
> loaded into Postgis with shp2pgsql and am using
> EPSG:4326.  I assume the Ellipsoid I'm retrieving
> isn't really what I want, or the
> getAreaOfInterest().getWidth() isn't returning
> anything that can be reliably converted.  Then again,
> maybe it's something else entirely.
>
> Any help would be greatly appreciated!
>
> Todd
>
>
> The only "dumb question" is the one you were too afraid to ask.
> ________________________________________
> Check out RouteRuler - Free software for runners, cyclists, walkers,
> etc.
> http://routeruler.sourceforge.net
> ________________________________________
> Get a handle on your data with "pocOLAP", the "little" OLAP project
> http://pocolap.sourceforge.net
> ________________________________________
>
>
>
>
> __________________________________
> Yahoo! for Good - Make a difference this year.
> http://brand.yahoo.com/cybergivingweek2005/
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through
> log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD
> SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Geoserver-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>




----------------------------------------------------------
This mail sent through IMP: https://webmail.limegroup.com/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Creating a scalebar to display distance

todd runstein
Chris,

Thank you!  That code was exactly what I needed!  I
don't have the actual scalebar working yet, but at
least I've got an accurate measurement.  Once I get
the image to generate correctly, I'll post the code as
you suggest.  

Thanks again!

Todd

--- Chris Holmes <[hidden email]> wrote:

> I would love to get a scalebar in GeoServer, if you
> get this working
> please do contribute the code back, just make a bug
> report and attach
> the code you wrote to the issue.  We can probably
> figure out how to
> make a UI so it's easier for others to set.
>
> As for the code, I personally have little idea, but
> our udig compatriots
> have a working scalebar, so in true open source
> fashion I'd just take a
> gander at what they did.  Jody gave this link:
>
http://svn.geotools.org/udig/trunk/plugins/net.refractions.udig.printing.ui/src/net/refractions/udig/printing/ui/ScalebarMapGraphic.java

> which looks like it might contain what you need.  If
> you have further
> questions on how it works just ask the udig list,
> and I'm sure they'll
> help you out.  The gt2 list may also be helpful.
>
> best regards,
>
> Chris
>
> Quoting todd runstein <[hidden email]>:
>
> > I'm trying to create something similar to the
> > "scalebar" found in MapServer.  I'm using brute
> force
> > to modify the image generated in the produceMap
> method
> > in
> >
>
org.vfny.geoserver.wms.responses.DefaultRasterMapProducer,

> > but am having trouble getting a valid measurement.
> >
> > Here's the code I'm using (starting at around line
> > 260):
> >
> > if (map==null ||
> > map.getCoordinateReferenceSystem()==null){
> >    System.out.println("Could not create a
> > measurement");
> > }else{
> >    DefaultEllipsoid e = (DefaultEllipsoid)
> >
>
CRSUtilities.getHeadGeoEllipsoid(map.getCoordinateReferenceSystem());

> >     Unit unit = e.getAxisUnit();
> >     Unit target = SI.METER;
> >     Converter c = unit.getConverterTo(target);
> >     double d =
> > c.convert(map.getAreaOfInterest().getWidth());
> >
> >     graphic.setColor(Color.BLACK);
> >     if (paintArea.width>200) {
> >       graphic.drawString("Distance may be " +
> > d,0,paintArea.height);
> >     }
> > }
> >
> > When the map first loads (using MapBuilder), it
> tells
> > me that the AreaOfInterest is approximately 1.09
> > meters, however it's showing all of Multnomah
> County,
> > Oregon (not sure what the total width is, but it's
> > certainly larger than what is shown).  Zooming in
> > changes the distance displayed in (what appears to
> be)
> > the correct proportion, though it is still
> woefully
> > short.
> >
> > I'm using Tiger data (obtained through a
> ShapeFile)
> > loaded into Postgis with shp2pgsql and am using
> > EPSG:4326.  I assume the Ellipsoid I'm retrieving
> > isn't really what I want, or the
> > getAreaOfInterest().getWidth() isn't returning
> > anything that can be reliably converted.  Then
> again,
> > maybe it's something else entirely.
> >
> > Any help would be greatly appreciated!
> >
> > Todd
> >
> >
> > The only "dumb question" is the one you were too
> afraid to ask.
> > ________________________________________
> > Check out RouteRuler - Free software for runners,
> cyclists, walkers,
> > etc.
> > http://routeruler.sourceforge.net
> > ________________________________________
> > Get a handle on your data with "pocOLAP", the
> "little" OLAP project
> > http://pocolap.sourceforge.net
> > ________________________________________
> >
> >
> >
> >
> > __________________________________
> > Yahoo! for Good - Make a difference this year.
> > http://brand.yahoo.com/cybergivingweek2005/
> >
> >
> >
>
-------------------------------------------------------

> > This SF.net email is sponsored by: Splunk Inc. Do
> you grep through
> > log files
> > for problems?  Stop!  Download the new AJAX search
> engine that makes
> > searching your log files as easy as surfing the
> web.  DOWNLOAD
> > SPLUNK!
> >
>
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> > _______________________________________________
> > Geoserver-users mailing list
> > [hidden email]
> >
>
https://lists.sourceforge.net/lists/listinfo/geoserver-users
> >
>
>
>
>
>
----------------------------------------------------------
> This mail sent through IMP:
> https://webmail.limegroup.com/
>


The only "dumb question" is the one you were too afraid to ask.
________________________________________
Check out RouteRuler - Free software for runners, cyclists, walkers, etc.
http://routeruler.sourceforge.net
________________________________________
Get a handle on your data with "pocOLAP", the "little" OLAP project
http://pocolap.sourceforge.net
________________________________________


               
__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

post using a URL connection

David Neufeld-2
Hi all,

I'm trying to do a wfs post using a URLConnection, so far without any luck.

Any samples available?

Here's what I'm trying, with a service exception thrown saying no request
recognized.

Thanks!
Dave

String wfsRequest ="<GetCapabilities
service='WFS'%20xmlns='http://www.opengis.net/wfs'%20xmlns:xsi='http://www.w
3.org/2001/XMLSchema-instance'%20xsi:schemaLocation='http://www.opengis.net/
wfs%20http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd'/>";
       
URL url = new URL("http://localhost:8080/geoserver/wfs");
                       
//String data = URLEncoder.encode(wfsRequest, "UTF-8");
String data = wfsRequest;

// Send data
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
                       
// Read in URL
String strContents = "";
String strReturn = "";
BufferedReader l_bfrIn = new BufferedReader(new
InputStreamReader(url.openStream()));
while ((strContents = l_bfrIn.readLine()) != null) {
  strReturn+=strContents;
}

System.out.println(strReturn);






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: post using a URL connection

Justin Deoliveira-3
Hi David,

I am at a bit of a loss here, I executed your code and to my suprise it
is getting treated as a GET request, not too sure why, I have made POST
requests like this many times and the method works fine.

Perhaps Magne has some time to take a quick look at this one. He was the
one who cracked the sending requests from a form issue, and this looks
like a similar issue.

-Justin

David Neufeld wrote:

> Hi all,
>
> I'm trying to do a wfs post using a URLConnection, so far without any luck.
>
> Any samples available?
>
> Here's what I'm trying, with a service exception thrown saying no request
> recognized.
>
> Thanks!
> Dave
>
> String wfsRequest ="<GetCapabilities
> service='WFS'%20xmlns='http://www.opengis.net/wfs'%20xmlns:xsi='http://www.w
> 3.org/2001/XMLSchema-instance'%20xsi:schemaLocation='http://www.opengis.net/
> wfs%20http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd'/>";
>
> URL url = new URL("http://localhost:8080/geoserver/wfs");
>
> //String data = URLEncoder.encode(wfsRequest, "UTF-8");
> String data = wfsRequest;
>
> // Send data
> URLConnection conn = url.openConnection();
> conn.setDoOutput(true);
> OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
> wr.write(data);
> wr.flush();
>
> // Read in URL
> String strContents = "";
> String strReturn = "";
> BufferedReader l_bfrIn = new BufferedReader(new
> InputStreamReader(url.openStream()));
> while ((strContents = l_bfrIn.readLine()) != null) {
>   strReturn+=strContents;
> }
>
> System.out.println(strReturn);
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> <a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
> _______________________________________________
> Geoserver-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>


--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Creating a scalebar to display distance

Chris Holmes-2
In reply to this post by todd runstein
Note that in the past couple days a nice javascript scalebar has
emerged.  See:
https://sourceforge.net/mailarchive/forum.php?thread_id=9394832&forum_id=475
If you're using mapbuilder it could be quite easy to get in.  And the
javascript code is available if you're using anything else.

After you've got things working, it would be great if you could put
something up in the User Experiences - how you got a scalebar working
would be great, or anything else you learned that wasn't quite in the
docs.  It can be informal.  And do submit the patch for geoserver if
you've got it creating a scalebar correctly.

best regards,

Chris

Quoting todd runstein <[hidden email]>:

> Chris,
>
> Thank you!  That code was exactly what I needed!  I
> don't have the actual scalebar working yet, but at
> least I've got an accurate measurement.  Once I get
> the image to generate correctly, I'll post the code as
> you suggest.
>
> Thanks again!
>
> Todd
>
> --- Chris Holmes <[hidden email]> wrote:
>
> > I would love to get a scalebar in GeoServer, if you
> > get this working
> > please do contribute the code back, just make a bug
> > report and attach
> > the code you wrote to the issue.  We can probably
> > figure out how to
> > make a UI so it's easier for others to set.
> >
> > As for the code, I personally have little idea, but
> > our udig compatriots
> > have a working scalebar, so in true open source
> > fashion I'd just take a
> > gander at what they did.  Jody gave this link:
> >
>
http://svn.geotools.org/udig/trunk/plugins/net.refractions.udig.printing.ui/src/net/refractions/udig/printing/ui/ScalebarMapGraphic.java

> > which looks like it might contain what you need.  If
> > you have further
> > questions on how it works just ask the udig list,
> > and I'm sure they'll
> > help you out.  The gt2 list may also be helpful.
> >
> > best regards,
> >
> > Chris
> >
> > Quoting todd runstein <[hidden email]>:
> >
> > > I'm trying to create something similar to the
> > > "scalebar" found in MapServer.  I'm using brute
> > force
> > > to modify the image generated in the produceMap
> > method
> > > in
> > >
> >
> org.vfny.geoserver.wms.responses.DefaultRasterMapProducer,
> > > but am having trouble getting a valid measurement.
> > >
> > > Here's the code I'm using (starting at around line
> > > 260):
> > >
> > > if (map==null ||
> > > map.getCoordinateReferenceSystem()==null){
> > >    System.out.println("Could not create a
> > > measurement");
> > > }else{
> > >    DefaultEllipsoid e = (DefaultEllipsoid)
> > >
> >
> CRSUtilities.getHeadGeoEllipsoid(map.getCoordinateReferenceSystem());
> > >     Unit unit = e.getAxisUnit();
> > >     Unit target = SI.METER;
> > >     Converter c = unit.getConverterTo(target);
> > >     double d =
> > > c.convert(map.getAreaOfInterest().getWidth());
> > >
> > >     graphic.setColor(Color.BLACK);
> > >     if (paintArea.width>200) {
> > >       graphic.drawString("Distance may be " +
> > > d,0,paintArea.height);
> > >     }
> > > }
> > >
> > > When the map first loads (using MapBuilder), it
> > tells
> > > me that the AreaOfInterest is approximately 1.09
> > > meters, however it's showing all of Multnomah
> > County,
> > > Oregon (not sure what the total width is, but it's
> > > certainly larger than what is shown).  Zooming in
> > > changes the distance displayed in (what appears to
> > be)
> > > the correct proportion, though it is still
> > woefully
> > > short.
> > >
> > > I'm using Tiger data (obtained through a
> > ShapeFile)
> > > loaded into Postgis with shp2pgsql and am using
> > > EPSG:4326.  I assume the Ellipsoid I'm retrieving
> > > isn't really what I want, or the
> > > getAreaOfInterest().getWidth() isn't returning
> > > anything that can be reliably converted.  Then
> > again,
> > > maybe it's something else entirely.
> > >
> > > Any help would be greatly appreciated!
> > >
> > > Todd
> > >
> > >
> > > The only "dumb question" is the one you were too
> > afraid to ask.
> > > ________________________________________
> > > Check out RouteRuler - Free software for runners,
> > cyclists, walkers,
> > > etc.
> > > http://routeruler.sourceforge.net
> > > ________________________________________
> > > Get a handle on your data with "pocOLAP", the
> > "little" OLAP project
> > > http://pocolap.sourceforge.net
> > > ________________________________________
> > >
> > >
> > >
> > >
> > > __________________________________
> > > Yahoo! for Good - Make a difference this year.
> > > http://brand.yahoo.com/cybergivingweek2005/
> > >
> > >
> > >
> >
> -------------------------------------------------------
> > > This SF.net email is sponsored by: Splunk Inc. Do
> > you grep through
> > > log files
> > > for problems?  Stop!  Download the new AJAX search
> > engine that makes
> > > searching your log files as easy as surfing the
> > web.  DOWNLOAD
> > > SPLUNK!
> > >
> >
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> > > _______________________________________________
> > > Geoserver-users mailing list
> > > [hidden email]
> > >
> >
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
> > >
> >
> >
> >
> >
> >
> ----------------------------------------------------------
> > This mail sent through IMP:
> > https://webmail.limegroup.com/
> >
>
>
> The only "dumb question" is the one you were too afraid to ask.
> ________________________________________
> Check out RouteRuler - Free software for runners, cyclists, walkers,
> etc.
> http://routeruler.sourceforge.net
> ________________________________________
> Get a handle on your data with "pocOLAP", the "little" OLAP project
> http://pocolap.sourceforge.net
> ________________________________________
>
>
>
> __________________________________________
> Yahoo! DSL – Something to write home about.
> Just $16.99/mo. or less.
> dsl.yahoo.com
>




----------------------------------------------------------
This mail sent through IMP: https://webmail.limegroup.com/


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
<a href="http://ads.osdn.com/?ad_idv37&alloc_id865&op=click">http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Creating a scalebar to display distance

todd runstein
Chris,

I'll definately add my User Experience to the site -
eventually.  

I like the javascript widget, though it doesn't work
for my purposes.  I need the scale embedded in the
image, much like they've embedded their copyright.
Still, the js widget is nice.

I have submitted the code for embedding the scale in
the map image (though it's really, really rough).  The
code can also be easily modified to embed a copyright
mark - or does that already exist in GeoServer
somewhere?

Todd


--- Chris Holmes <[hidden email]> wrote:

> Note that in the past couple days a nice javascript
> scalebar has
> emerged.  See:
>
https://sourceforge.net/mailarchive/forum.php?thread_id=9394832&forum_id=475

> If you're using mapbuilder it could be quite easy to
> get in.  And the
> javascript code is available if you're using
> anything else.
>
> After you've got things working, it would be great
> if you could put
> something up in the User Experiences - how you got a
> scalebar working
> would be great, or anything else you learned that
> wasn't quite in the
> docs.  It can be informal.  And do submit the patch
> for geoserver if
> you've got it creating a scalebar correctly.
>
> best regards,
>
> Chris
>
> Quoting todd runstein <[hidden email]>:
>
> > Chris,
> >
> > Thank you!  That code was exactly what I needed!
> I
> > don't have the actual scalebar working yet, but at
> > least I've got an accurate measurement.  Once I
> get
> > the image to generate correctly, I'll post the
> code as
> > you suggest.
> >
> > Thanks again!
> >
> > Todd
> >
> > --- Chris Holmes <[hidden email]> wrote:
> >
> > > I would love to get a scalebar in GeoServer, if
> you
> > > get this working
> > > please do contribute the code back, just make a
> bug
> > > report and attach
> > > the code you wrote to the issue.  We can
> probably
> > > figure out how to
> > > make a UI so it's easier for others to set.
> > >
> > > As for the code, I personally have little idea,
> but
> > > our udig compatriots
> > > have a working scalebar, so in true open source
> > > fashion I'd just take a
> > > gander at what they did.  Jody gave this link:
> > >
> >
>
http://svn.geotools.org/udig/trunk/plugins/net.refractions.udig.printing.ui/src/net/refractions/udig/printing/ui/ScalebarMapGraphic.java

> > > which looks like it might contain what you need.
>  If
> > > you have further
> > > questions on how it works just ask the udig
> list,
> > > and I'm sure they'll
> > > help you out.  The gt2 list may also be helpful.
> > >
> > > best regards,
> > >
> > > Chris
> > >
> > > Quoting todd runstein <[hidden email]>:
> > >
> > > > I'm trying to create something similar to the
> > > > "scalebar" found in MapServer.  I'm using
> brute
> > > force
> > > > to modify the image generated in the
> produceMap
> > > method
> > > > in
> > > >
> > >
> >
>
org.vfny.geoserver.wms.responses.DefaultRasterMapProducer,

> > > > but am having trouble getting a valid
> measurement.
> > > >
> > > > Here's the code I'm using (starting at around
> line
> > > > 260):
> > > >
> > > > if (map==null ||
> > > > map.getCoordinateReferenceSystem()==null){
> > > >    System.out.println("Could not create a
> > > > measurement");
> > > > }else{
> > > >    DefaultEllipsoid e = (DefaultEllipsoid)
> > > >
> > >
> >
>
CRSUtilities.getHeadGeoEllipsoid(map.getCoordinateReferenceSystem());

> > > >     Unit unit = e.getAxisUnit();
> > > >     Unit target = SI.METER;
> > > >     Converter c = unit.getConverterTo(target);
> > > >     double d =
> > > > c.convert(map.getAreaOfInterest().getWidth());
> > > >
> > > >     graphic.setColor(Color.BLACK);
> > > >     if (paintArea.width>200) {
> > > >       graphic.drawString("Distance may be " +
> > > > d,0,paintArea.height);
> > > >     }
> > > > }
> > > >
> > > > When the map first loads (using MapBuilder),
> it
> > > tells
> > > > me that the AreaOfInterest is approximately
> 1.09
> > > > meters, however it's showing all of Multnomah
> > > County,
> > > > Oregon (not sure what the total width is, but
> it's
> > > > certainly larger than what is shown).  Zooming
> in
> > > > changes the distance displayed in (what
> appears to
> > > be)
> > > > the correct proportion, though it is still
> > > woefully
> > > > short.
> > > >
> > > > I'm using Tiger data (obtained through a
> > > ShapeFile)
> > > > loaded into Postgis with shp2pgsql and am
> using
> > > > EPSG:4326.  I assume the Ellipsoid I'm
> retrieving
> > > > isn't really what I want, or the
> > > > getAreaOfInterest().getWidth() isn't returning
> > > > anything that can be reliably converted.  Then
> > > again,
> > > > maybe it's something else entirely.
> > > >
> > > > Any help would be greatly appreciated!
> > > >
> > > > Todd
> > > >
> > > >
> > > > The only "dumb question" is the one you were
> too
> > > afraid to ask.
> > > > ________________________________________
> > > > Check out RouteRuler - Free software for
> runners,
> > > cyclists, walkers,
> > > > etc.
> > > > http://routeruler.sourceforge.net
> > > > ________________________________________
> > > > Get a handle on your data with "pocOLAP", the
> > > "little" OLAP project
> > > > http://pocolap.sourceforge.net
> > > > ________________________________________
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________
> > > > Yahoo! for Good - Make a difference this year.
> > > > http://brand.yahoo.com/cybergivingweek2005/
> > > >
> > > >
> > > >
> > >
> >
>
-------------------------------------------------------

> > > > This SF.net email is sponsored by: Splunk Inc.
> Do
> > > you grep through
> > > > log files
> > > > for problems?  Stop!  Download the new AJAX
> search
> > > engine that makes
> > > > searching your log files as easy as surfing
> the
> > > web.  DOWNLOAD
> > > > SPLUNK!
> > > >
> > >
> >
>
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> > > >
> _______________________________________________
> > > > Geoserver-users mailing list
> > > > [hidden email]
> > > >
> > >
>
=== message truncated ===


The only "dumb question" is the one you were too afraid to ask.
________________________________________
Check out RouteRuler - Free software for runners, cyclists, walkers, etc.
http://routeruler.sourceforge.net
________________________________________
Get a handle on your data with "pocOLAP", the "little" OLAP project
http://pocolap.sourceforge.net
________________________________________


               
__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geoserver-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geoserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Creating a scalebar to display distance

alexander-petkov
On 1/6/06, todd runstein <[hidden email]> wrote:

> Chris,
>
> I'll definately add my User Experience to the site -
> eventually.
>
> I like the javascript widget, though it doesn't work
> for my purposes.  I need the scale embedded in the
> image, much like they've embedded their copyright.
> Still, the js widget is nice.
>
> I have submitted the code for embedding the scale in
> the map image (though it's really, really rough).  The
> code can also be easily modified to embed a copyright
> mark - or does that already exist in GeoServer
> somewhere?
>
> Todd

Hello Todd:
Let's see a picture!!! Also, where did you submit the code?

Thanks,
Alex
N�HY޵隊X���'���u���[�������
ަ�k��!���W�~�鮆�zk��C� 塧m����@^ǚ��^��z�Z�f�z�j�!�x2�������ɫ,��� a{� �,�H��4�m���i�(��ܢo�v'��jYhr'ׯ:�rX��g����z��z�&j)b� b�ў�ǫ�����+-��.�ǟ����a��l��b��,���y�+��޷�b��?�+-�w������z��z�
Reply | Threaded
Open this post in threaded view
|

Re: Creating a scalebar to display distance

todd runstein
Alex,

"Code" might be a bit of an overstatement - this is
clearly a hack designed to solve a specific problem.
On the other hand, it does what I need:

http://jira.codehaus.org/browse/GEOS-517

I hope someone has the time and talent to make this
configurable.

Todd



--- Alexander Petkov <[hidden email]> wrote:

> On 1/6/06, todd runstein <[hidden email]> wrote:
> > Chris,
> >
> > I'll definately add my User Experience to the site
> -
> > eventually.
> >
> > I like the javascript widget, though it doesn't
> work
> > for my purposes.  I need the scale embedded in the
> > image, much like they've embedded their copyright.
> > Still, the js widget is nice.
> >
> > I have submitted the code for embedding the scale
> in
> > the map image (though it's really, really rough).
> The
> > code can also be easily modified to embed a
> copyright
> > mark - or does that already exist in GeoServer
> > somewhere?
> >
> > Todd
>
> Hello Todd:
> Let's see a picture!!! Also, where did you submit
> the code?
>
> Thanks,
> Alex
> N¬HY޵隊X¬²š'²ŠÞu¼’¦[§‰ÜŒ¨º
> Þ¦Øk¢è!–ˆŠW¬~Šé®†åzk¶ŠC£
>
塧m…éÞÀ@^ǚ­È^ž§zØZ¶f¤zËj·!Šx2¢êå¢â•ë±æ¬É«,º·âž a{› å,àHòÔ4¨m¶ŸÿiÛ(±ÙÜ¢oÚv'ï­ûjYhr'ׯ:æŠrXœg¨±êïz»¬z»&j)bž b²Ñž¢Ç«½êî±êì–+-²Ê.­ÇŸ¢¸ëa¶Úlÿùb²Û,¢êÜyú+éÞ·ùb²Û?–+-Šwèþ¨±êïz»¬z»

The only "dumb question" is the one you were too afraid to ask.
________________________________________
Check out RouteRuler - Free software for runners, cyclists, walkers, etc.
http://routeruler.sourceforge.net
________________________________________
Get a handle on your data with "pocOLAP", the "little" OLAP project
http://pocolap.sourceforge.net
________________________________________


               
__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com

Screenshot.jpg (37K) Download Attachment