On Wed, Aug 29, 2012 at 3:07 PM, LSA <[email protected]> wrote:

> Hi all,
>
> I am using the following code to find out the number of features in the
> shapefile:
>
> public static int getFeatureCount(String shapefilePath)
> {
> ShapefileDataStore shapefileDataStore = ...;
> FeatureSource featureSource =
> shapefileDataStore.getFeatureSource(shapefileDataStore.getTypeNames()[0]);
> return featureSource.getCount(Query.ALL);
>
> }
>
> But it is very slow.
>

Err... all that code should be doing is opening the shx file, reading the
header,
get the declared count out of it, and return back the result.
Unless your shapefile either have no .shx file or the header of it is broken
(e.g., contains a negative number)

Cheers
Andrea

-- 
==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more
information.
==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:   +39 0584 962313
mob:   +39  339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to