[mapserver-users] couldn't get value from raster map

Ahmet Temiz temiz at deprem.gov.tr
Sun Sep 27 06:46:05 EDT 2009


hello

I am using java mapscript and trying to get values from raster layer.

But I can only get x,y values but not other values especially color values of
the pixel I had clicked. 

here is the my code's fragment : 

int q = slplayer.queryByPoint(map0, qpt, mapscript.MS_MULTIPLE, 10.0 );
int numResults = slplayer.getNumResults();

if (numResults != 0) {
	for (int j = 0; j < numResults; j++) {
		resultCacheMemberObj resultMember = slplayer.getResult(j);
		slplayer.open();
		shapeObj shape = new shapeObj(slplayer.getType()
				.swigValue());
		int s = slplayer.getShape(shape, resultMember.getTileindex(),
				resultMember.getShapeindex());

               System.out.println(" *** s "+s);   -----> 0

		
		if (shape != null) {
			
		System.out.println(" *** numResults "+numResults); ----> 2
			
		int shpix = shape.getIndex();
		
		System.out.println(" *** shpix "+shpix);  ! -------> -1
			
		System.out.println(" *** shape.getValue "+shape.getValue(j));  -----> only
gives x,y values bot not RGB values
			
		}
		slplayer.close();
	}

here is the related part of map file : 

LAYER
  NAME "slp_cat"
  STATUS OFF
  TILEINDEX "/home/orkun/data/hsunucu/mapshar/rast_index.shp"
  TILEITEM "Location"
  TYPE RASTER
  TEMPLATE "/home/orkun/workspace2/pro1/WebContent/Raster_Query.html"
  PROCESSING "SCALE=1,9"
  #PROCESSING "SCALE_BUCKETS=9"
  CLASS
    NAME "0-5"
    EXPRESSION ([pixel] =1)
    STYLE
      COLOR 254 254 25
    END
  END
 
  CLASS
    NAME "5-10"
    EXPRESSION ([pixel] =2)
    STYLE
      COLOR 249 177 20
    END
  END
   CLASS
    NAME "10-15"
    EXPRESSION ([pixel] =3)
    STYLE
      COLOR 25 254 82
    END
  END

   CLASS
    NAME "15-20"
    EXPRESSION ([pixel] =4)
    STYLE
      COLOR 25 254 225
    END
  END
   
  CLASS
    NAME "20-25"
    EXPRESSION ([pixel] =5)
    STYLE
      COLOR 25 140 254
    END
  END

  CLASS
    NAME "30-35"
    EXPRESSION ([pixel] =6)
    STYLE
      COLOR 53 25 254
    END
  END

  CLASS
    NAME "35-45"
    EXPRESSION ([pixel] =7)
    STYLE
      COLOR 196 25 254
    END
  END

  CLASS
    NAME "35-45"
    EXPRESSION ([pixel] =8)
    STYLE
      COLOR 254 25 169
    END
  END

  CLASS
    NAME "45-90"
    EXPRESSION ([pixel] =9)
    STYLE
      COLOR 254 25 25
    END
  END

 END

~~~~~~~~~~~~~~~~~

 Could you possibly tell me where I am wrong ?

 kind regards

--
Open WebMail Project (http://openwebmail.org)


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the mapserver-users mailing list