Ushant Suman (21) [Avatar] Offline
#1
Hi,

In listing 7.2 I need help in understanding the dimension of output raster How the size of output raster comes to 60pixel wide and 155 pixels height after running the code??
regina.leo (260) [Avatar] Offline
#2
This is tough to explain, but here's my best effort. Let me know if I can clarify.

1) You start with a canvas that is 500 x 500 pixels, where each pixel represents 2 meters
2) When you use ST_AsRaster with an empty raster and a geometry (essentially aligning the geometry with the raster), the resulting raster has the dimension in pixels of what you would get by intersecting the empty raster's geometric box with the geometry



Here is a query which hopefully clarifies it a bit:

It answers the question of what is the Intersection of the geometry and the empty raster (expressed as a geometry-- use ST_MakeEnvelope for that)

and then what is the bounding box of this intersection expressed in pixel units. Each meter is 1/2 pixel since each pixel represents 2 meters in height and width.

With d As (
-- returns the box of the intersection of the raster / geometry in spatial ref units (meters)
SELECT ST_Intersection(ST_Buffer('LINESTRING(
448252 5414206,448289 5414317,448293 5414330,
448324 5414417,448351 5414495)',10)::geometry, ST_MakeEnvelope(445000,445000 + 500/2,5415000 - 500/2, 5415000 ) )::box2d AS box)

-- units in pixels, we divide by two because each meter = 1/2 a pixel width by 1/2 pixel height
SELECT (ST_XMax(box) - ST_XMin(box))/2 AS width, (ST_YMax(box) - ST_YMin(box))/2 As height
FROM d

-- this returns

width | height
------------------+------------------
59.4785864696023 | 154.478586469777
(1 row)


Since pixels have to be whole numbers, this gets rounded up to 60 x 155


-- you can check the results also by just running the query and getting the width and height of resulting
raster

WITH
r AS
(SELECT
ST_MakeEmptyRaster(
500,500,445000,5415000,2,-2,0,0,32631
) As rast
),
g AS
(SELECT ST_Buffer(
ST_GeomFromText(
'LINESTRING(
448252 5414206,448289 5414317,448293 5414330,
448324 5414417,448351 5414495)',
32631),
10) As geom
),
f AS (
SELECT 'canvas aligned road', ST_AsRaster(geom,rast,'8BUI'::text) As rast
FROM r CROSS JOIN g)

SELECT ST_Width(rast), ST_Height(rast)
FROM f;

-- yields

st_width | st_height
----------+-----------
60 | 155
(1 row)


Ushant Suman (21) [Avatar] Offline
#3
It means that first we are calculating the intersection points between linestring and treating the empty raster as a box and since the intersection is in meters we convert it into equivalent pixel by dividing 1/2.
regina.leo (260) [Avatar] Offline
#4
Sorry didn't see this one. Is that statement unclear to you? I can try to a different way of explaining it if it is.
Ushant Suman (21) [Avatar] Offline
#5
No its ok.Thanks for the explanation.
Ushant Suman (21) [Avatar] Offline
#6
Help required in displaying the postgis table data in UTM43N projection in web browser
Hi,

I have a table in postgis which is storing point data of around 500 points of different fields.My plan is to create the layertree in GeoEXT and when the user click on the check box of the layer tree the points pertaining to that field should be displayed in planer UTM projection.

I am using this approach
1)capture the user click
2) pass it as a parameter in php script
3) write stored function in postgresql and convert the geometry in required SRID andwhich output in geojson.
4)parse json in UI and display in web browser.
2 nd approach
1) Make each view for each field points or based on filtering criteria and publish these views in geoserver if possible in UTM projection and display it in client treting each view as WMS source??

Am I thinking in right direction or something else needs to be done.please guide me.


regina.leo (260) [Avatar] Offline
#7
-- correction, sorry didn't see the second approach was separate from first. So have updated my answer.

Both approaches are valid, but for your particular use case of rendering just points, I'd go with one.
It might take a bit more thinking, but in long run it's more flexible, reduces number of services you need, and is less taxing on server unless you are caching data as well.


I'd only both with GeoServer or any Mapping server for that matter, if I have large amounts of data (like in the thousands or millions) that is more efficiently sent over to the client as an image or if I need export functionality like export in shape or kml or whatever that GeoServer supports. or if you need caching support.

Oops forgot about other reason to go with GeoServer and other Mapping servers. For labeling and general styling neither OpenLayers nor Leaflet do that great a job of that. So for rendering things like Roads where styling becomes really important, that also where GeoServer and MapServer shine.
Ushant Suman (21) [Avatar] Offline
#8
Help required for displaying points in the whole browser frame
I have a postgis table of around 100 points I have published it using geoserver and for styling I modified the SLD and using GEoEXT for tree panel my code is some thing like this
var mapPanel, tree;

Ext.application({
name: 'Tree',
launch: function() {
// create a map panel with some layers that we will show in our layer tree
// below.
mapPanel = Ext.create('GeoExt.panel.Map', {
border: true,
region: "center",
// we do not want all overlays, to try the OverlayLayerContainer
map: {allOverlays: false},
center: [72.369949, 23.586761],
zoom: 30,
layers: [
new OpenLayers.Layer.WMS("MANSA",
"http://localhost:8080/geoserver/NaturalEarth/wms", {
layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()]
}, {
buffer: 0,
visibility: false,
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'MANSA'"
}
),
new OpenLayers.Layer.WMS("LANGANAJ",
"http://localhost:8080/geoserver/NaturalEarth/wms",
{layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()],
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'LANGHNAJ'"
}

)



// create a group layer (with several layers in the "layers" param)
// to show how the LayerParamLoader works

]
});

My points do not spread in the whole frame of browser even after zooming.I dont understand why??please help.It shows only 2 points very close and after zomming there is no display of labels
regina.leo (260) [Avatar] Offline
#9
HArd to tell by looking at your code what is wrong.

Did you confirm from GeoServer you are getting back all the points.

Your browser (firefox and google I know have one), in developer console, you can see the network calls to GeoServer. Run one of those to see the output.
Ushant Suman (21) [Avatar] Offline
#10
I have tried to resolve the previous issues with this code:
layers: [
new OpenLayers.Layer.WMS("MANSA",
"http://localhost:8080/geoserver/NaturalEarth/wms", {
layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()]
}, {
buffer: 0,
visibility: false,
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'MANSA'",
restrictedExtent:[72.4476470947266, 23.3986797332764,
72.6516571044922, 23.6165523529053],
maxResolution: 'auto'

}
),
new OpenLayers.Layer.WMS("LANGANAJ",
"http://localhost:8080/geoserver/NaturalEarth/wms",
{layers: "NaturalEarth:Wells",
strategies: [new OpenLayers.Strategy.BBOX()],
isBaseLayer: false,
geometryName: "geom",
CQL_FILTER: "field = 'LANGHNAJ'",
maxExtent:[72.4476470947266, 23.3986797332764,
72.6516571044922, 23.6165523529053],
maxResolution: 'auto',
numZoomLevels:19
}

)
It seems to be working bt the only problem with the zoom level.Is there any way in Openlayers 2.10 to increase the zoom level beyond 16.
regina.leo (260) [Avatar] Offline
#11
From my recollection there is no hard-coded zoom limit of 16 in OpenLayers 2 or 3.

The hard-coded limit is on the WMS level like geoserver or mapserver or your tile server.

For example I think USGS limits you to a zoom level of 15 or 16 if you want to pull their tiles.

If you are using your own GeoServer and have it set to build tiles, you might want to check the max level it is set to build.