[OpenMap Users] Search AreaShapeLayer

From: JayDub <justcallmejay_at_gmail.com>
Date: Sun, 31 May 2009 22:29:29 -0700 (PDT)

Hi all... I need to search an AreaShapeLayer's dbf file. I've tried the
following:
However.. I get a NullPointerException whennever I tried to access any
record related methods like getRecord(int i) or even itr.next() on the
iterator from getRecords. I've chcked over and over.. the "model" is not
null either. The app successfully prints out the number of records.

    public static void search(ShapeLayer sLayer, String query, int column){
            Properties layerProps = sLayer.getProperties(null);
            String prefix = sLayer.getPropertyPrefix() + ".";
            String dbfFileLocation = layerProps.getProperty(prefix +
"shapeFile");
            dbfFileLocation = dbfFileLocation.replaceAll(".shp", ".dbf");
// <-- this is a hack... we can't access the dbfFile property... openmap
deletes it on shp layer load... dunno y
            // we assume that the dbf file has the same name

            DbfTableModel model = DbfFile.getDbfTableModel(dbfFileLocation);
            System.out.println(model.getColumnCount() + " columns");
            if(model != null){
                Iterator itr = model.getRecords();
                while(itr.hasNext()){
                    Object obj = itr.next();
                }
            }
    }

-- 
View this message in context: http://www.nabble.com/Search-AreaShapeLayer-tp23808433p23808433.html
Sent from the OpenMap mailing list archive at Nabble.com.
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Jun 01 2009 - 01:30:16 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT