On Sat, Nov 30, 2013 at 10:37 PM, Jared Erickson
<jared.erick...@gmail.com>wrote:

> Hi all,
>
> I am working on adding OGR support to GeoScript and noticed that reading
> SQLite databases currently fails because SQLite doesn't support FID.  So I
> get the following error:
>
> ERROR 1: In ExecuteSQL(): sqlite3_prepare(SELECT FID, * FROM 'points' ):
> no such column: FID
>
> because of this line of code:
>
>
> https://github.com/geotools/geotools/blob/master/modules/unsupported/ogr/ogr-core/src/main/java/org/geotools/data/ogr/OGRFeatureSource.java#L308


Yes, makes sense. Mind, this is a bit annoying since you'll have to update
both native implementations, the Swig based one (used on Mac),
and the BridJ based one (tested on Linux and Windows instead).


>
>
> Now the OGR C API has a function called OGR_L_GetFIDColumn that we could
> use to get the FID column for a Layer or an empty string if its not
> supported but FID is also used for sorting.
>
>
> https://github.com/geotools/geotools/blob/master/modules/unsupported/ogr/ogr-core/src/main/java/org/geotools/data/ogr/OGRFeatureSource.java#L333
>
> I am not sure what to do about the FID usage for sorting if the
> OGR_L_GetFIDColumn call returns an empty string.
>

I guess you can mimic the JDBCDataStore behavior:

                if(SortBy.NATURAL_ORDER.equals(sort[i])||
SortBy.REVERSE_ORDER.equals(sort[i])) {
                    if(key instanceof NullPrimaryKey)
                        throw new IOException("Cannot do natural order
without a primary key");

Ideally, it would be better to update the feature source QueryCapabilities
to return false when
there is no FID and natural or reverse orders are requested, which is also
something JDBCDataStore family
gets right in its JDBCQueryCapabilities class:

    public boolean supportsSorting(final SortBy[] sortAttributes) {
        if(super.supportsSorting(sortAttributes))
            return true;

        for (int i = 0; i < sortAttributes.length; i++) {
            SortBy sortBy = sortAttributes[i];
            if (SortBy.NATURAL_ORDER == sortBy || SortBy.REVERSE_ORDER ==
sortBy) {
                // we do only if we have a non null primary key
                return !(source.getPrimaryKey() instanceof NullPrimaryKey);
            } else {
                PropertyName propertyName = sortBy.getPropertyName();
                SortOrder sortOrder = sortBy.getSortOrder();
                if (!supportsPropertySorting(propertyName, sortOrder)) {
                    return false;
                }
            }
        }
        return true;
    }


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 1660272
mob: +39  339 8844549

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

-------------------------------------------------------
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to