[mapserver-users] Mapscript Rasterquery returns empty result

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Wed Jun 2 04:23:17 PDT 2010


Hi,
 
LAYER TEMPLATE "dummy.html"?
 
Does such a thing exist? Have you tried with plain
 TEMPLATE "dummy.html"?
 
-Jukka Rahkonen-
 



________________________________

	Lähettäjä: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] Puolesta Tom van der Putte
	Lähetetty: 2. kesäkuuta 2010 13:34
	Vastaanottaja: Frank Warmerdam; Alexander Petkov
	Kopio: mapserver-users at lists.osgeo.org
	Aihe: Re: Re: [mapserver-users] Mapscript Rasterquery returns empty result
	
	
	Hi Frank, Alexander,
	
	Again thanks for your reply; I've been abroad for a month and haven't had time to check it out. However, I've ben doing some work on it today, and tested the following:
	
	I made a test tiff, with 2 large areas surrounded by NoData. When clicking anywhere in any one of the 2 big areas I get the response:
	
	{"_handle_":Resource id #47,"numlines":1,"type":0,"index":-1,"tileindex":-1,"classindex":0,"numvalues":8,"text":"","bounds":{"_handle_":Resource id #48,"minx":401265.0032,"miny":633815.31,"maxx":401265.0032,"maxy":633815.31},"values":[null,null,null,null,null,null,null,null]}
	
	When I click on any nodata area the response is  
	Warning: [MapServer Error]: msQueryByPoint(): No matching record(s) found. in C:\ms4w\apps\fusion\MapServer\php\GetRasterPoint.php on line 36
	
	Fatal error: [MapServer Error]: msRASTERLayerGetShape(): Out of range shape index requested. Requested 0 but only 0 shapes available. in C:\ms4w\apps\fusion\MapServer\php\GetRasterPoint.php on line 42
	
	
	
	This behaviour follows the edges of the areas perfectly. Also I checked it out with fixed coord pairs, and it doesn't seem te related to CRS problems. I've also tried IMG instead of TIFF, but no difference there.
	
	
	
	As mentioned, I'm running mapscript 5.2.1, not 5.6. I'm don't know if this would make a difference, but perhaps someone could test this for me? 
	
	
	
	The TIFF I use for testing is available from:  http://www.vdputte.nl/test_tiff.rar
	*** For the MAP part of the mapfile, I use the following (I removed most non-essential things):
	    EXTENT -1000000 -1200000 2902206 1773859
	    IMAGETYPE PNG24
	    SIZE 600 600
	    STATUS ON
	    UNITS METERS
	    NAME "Test_Map"
	
	    PROJECTION
	        'proj=lcc'
	        'lat_1=52.67000000000002'
	        'lat_2=54.33'
	        'lat_0=48'
	        'lon_0=10'
	        'x_0=815000'
	        'y_0=0'
	        'ellps=intl'
	        'units=m'
	        'no_defs'
	    END
	
	*** For the test LAYER:
	
	    LAYER
	      NAME "mask"
	      DATA "c:/ms4w/Apache/htdocs/data/rasters/depthmaps/tert_msk_rast.img"
	      TYPE RASTER
	      STATUS ON
	        LAYER TEMPLATE "dummy.html"
	      CLASS
	        NAME "1"
	        EXPRESSION ([pixel] == 1)
	        STYLE
	            color 255 0 0 
	        END        
	      END
	      CLASS
	        NAME "2"
	        EXPRESSION ([pixel] == 2)
	        STYLE
	            color 0 255 0 
	        END        
	      END
	    END#layer
	
	*** For the querying script I use this:
	
	$szLayer = "mask"; 
	$oLayer = $oMap->getLayerByName($szLayer); //get Layer
	$oMap->prepareQuery();
	
	// To be sure no CRS problems arise, I use these coords, smack in the middle of the left area
	$x = 360429;
	$y = 642536;
	
	/* 
	//For NoData, use
	$x = 759753;
	$y = 935658;
	// for a point right between the 2 areas
	*/
	
	$oPoint = ms_newPointObj(); //Create Point
	$oPoint->setXY($x,$y);
	
	$status = $oLayer->queryByPoint($oPoint, MS_MULTIPLE, 1); //Query
	$status = $oLayer->open();
	$result = $oLayer->getResult(0); //Get Result
	$numResults = $oLayer->getNumResults();
	
	$shape = $oLayer->getShape($result->shapeindex,$result->tileindex); // Retrieve shape
	
	echo(var2json($shape)); //echo to browser
	
	
	Can anybody confirm that they get the same behaviour?
	
	Cheers,
	Tom
	
	
	
	On Thu 29/04/10 16:07 , Frank Warmerdam warmerdam at pobox.com sent:
	

		Tom van der Putte wrote:
		> Hi,
		> 
		> I have the following code:
		> 
		> $oMap->prepareQuery();
		> $oPoint = ms_newPointObj();
		> $oPoint->setXY($x,$y); //coords received from a AJAX call
		> 
		> 
		> $oLayer = $oMap->GetLayerByName($szLayer); //Name received from a AJAX call
		> $status = $oLayer->queryByPoint($oPoint, MS_MULTIPLE, 1);
		> $status = $oLayer->open();
		> $result = $oLayer->getResult(0);
		> $numResults = $oLayer->getNumResults();
		> $shape = $oLayer->getShape($result->shapeindex,$result->tileindex);
		> echo(var2json($shape));
		> 
		> This results in the follwing json code to be returned:
		> 
		> |{"_handle_":Resource id #45,"numlines":1,"type":0,"index":-1,
		> 
		> "tileindex":-1,"classindex":0,"numvalues":8,"text":"",
		> 
		> "bounds":{"_handle_":Resource id #46,"minx":607000,
		> 
		> "miny":677000,"maxx":607000,"maxy":677000},
		> 
		> "values":[null,null,null,null,null,null,null,null]}|
		> 
		> No matter what I try, it keeps returning empty shapes. How can this be?
		
		Tom,
		
		I agree with Alexander that you should be carefully reviewing your
		input coordinate and insuring it is in the same coordinate system
		as the raster file. The returned values are expected if you are
		attempting to fetch a non-existant result shape.
		
		If you simplify your test case down as much as you can and you still
		can't figure out why you do not get a result then you could try to
		bundle this up and submit it as a ticket. Keep in mind that such a
		ticket is much more likely to be acted on if you make it *easy* for
		the developer to reproduce your problem.
		
		Best regards,
		-- 
		---------------------------------------+--------------------------------------
		I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com <javascript:top.opencompose('warmerdam at pobox.com','','','')> 
		light and sound - activate the windows | http://pobox.com/~warmerdam
		and watch the world go round - Rush | Geospatial Programmer for Rent
		
		
		

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100602/6acb0547/attachment.htm>


More information about the MapServer-users mailing list