Re: [OpenMap Users] ShapeAreaLayer Search

From: JayDub <justcallmejay_at_gmail.com>
Date: Mon, 1 Jun 2009 09:12:44 -0700 (PDT)

Okay... think it's only prudent that I add the solutions I've come across so
far.
First of all... I stopped using an AreaShapeLayer and started using an
EsriLayer. That made things much easier in terms of the dbf file access. I
was able to call getModel() on the EsriLayer and then loop over the rows. No
NPE's there.
I have a new problem however.... I need to label the shp layer. Apparently I
can't use the .rule property to get it labelled??? How do I label the
attributes in the shp layer or must I add my own text objects?


JayDub wrote:
>
> 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/ShapeAreaLayer-Search-tp23810155p23817570.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 - 12:13:30 EDT

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