Hi Elly,

The "scale factor" mentioned there is actually a measure of the
distortion involved in a given map projection. Wikipedia has the
mathematical details if you want to know more.

Back to your issue... It sounds like all you really need to do is sort
your shapefiles on their geographic extent. You don't have to display
them to do that. Basically, you can take bits of the Quickstart
example application as a guide to opening a shapefile, and then
instead of displaying it just record its extent. Something like
this...

// A class field
Map<String, ReferencedEnvelope> boundsLookup = new HashMap...

public void getShapefileExtent( String shpFileName ) throw Exception {
        File file = new File( shpFileName );
        FileDataStore store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();
        ReferencedEnvelope bounds = featureSource.getBounds();
        boundsLookup.put( shpeFileName, bounds );
}

If you are working with more than one map projection across the
shapefiles you could add a step to transform the bounding envelope to
a common CoordinateReferenceSystem of your choice. See the CRS
tutorial if you need an into to using CoordinateReferenceSystems:

http://docs.geotools.org/latest/userguide/tutorial/geometry/geometrycrs.html

Hope this helps,

Michael


On 4 August 2011 17:57, yixixi <[email protected]> wrote:
> Thanks Michael, you cleared very well. I thought a shp has a scale because I
> read on the shapefile-Wiki-page (http://en.wikipedia.org/wiki/Shapefile) the
> following section:
>
> The information contained in the .prj file specifies the:
>    Name of Geographic coordinate system or Map projection
>    Datum (geodesy)
>    Spheroid
>    Prime meridian
>    Units used
>    Parameters necessary to define the map projection, for example:
>        Latitude of origin
>        *Scale factor*
>
> I have a big list of maps (worldmap, citymap...) in shp and want to sort
> them by scale. Should I display all maps on JMapPane with same size and then
> calculate the scale again.
>
> Elly.
>
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/How-to-get-scale-from-shapefile-tp6651639p6651740.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
> The must-attend event for mobile developers. Connect with experts.
> Get tools for creating Super Apps. See the latest technologies.
> Sessions, hands-on labs, demos & much more. Register early & save!
> http://p.sf.net/sfu/rim-blackberry-1
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to