How to apply buffer in MapServer WMS query? - wms

I am trying to add a pixel buffer around a WMS query in MapServer. I noticed in MapServer/mapwms.cpp there is an option to set 'tiled=true' which should check for "tile_map_edge_buffer" "100" value in the map config file. However, when I check the spatial query, it doesn't seem to extend at all. Even altering SQL query to include extra data using ST_Expand(!BOX!, 0.01) doesn't help - the query does return extra data but it is not drawn.
I need this as I am generating point data through WMS EPSG:4326. The point data is displayed as large squares (changes with zoom level) but the data from the next tile near the border don't get generated in the tile of interest.
For example if the point on the main tile (lets say 100x100) is on (50,1), square size 20 pixels, the main tile generates a rectangle approx: (40,1 40,11 60,11 60,1) (20x10) which is correct. If I try to generate left side tile, I would expect to see the remainder of the square but I don't.
Anyway, if anyone had luck setting up pixel buffer for WMS, I would appreciate their input.

Related

AS3 - How to calculate intersection between drawing and bitmap

I'm trying to create a handwriting game with AS3 on Adobe Animate. I've created my board, functions(drawing, erasing, saving, printing and color pannel) so far. But i need to show a score. To do it i thought if i can calculate the percentege of intersection between drawing and a bitmap image(which is my background for now).
Is there any way to do it? Or can you at least tell me with which function should i try that? Thanks a lot.
Note: Here is 2 images from my game. You can easily understand what am i trying to explain and do.
players will try to draw correctly(drawn board)
Empty Board
just a suggestion,
lets assuming that you are recording draw data, a set of points according the frame rate that records mouse positions inside an array.
i used 8 points in my own example, the result would be like this: (6 of 8 = 75% passed)
► black line is correct path(trace btimap) ► red is client draw
we need to search whole of the points array and validate them, so a percentage will be gain easily
how to validate
each point contain x and y, to check if its placed on a black pixel (bitmap trace) we just do
if (bitmapData.getPixel(point.x, point.y) == 0x0) // 0x0 is black
getPixel returns an integer that represents an RGB pixel value from a
BitmapData object at a specific point (x, y). The getPixel() method
returns an unmultiplied pixel value. No alpha information is returned.
Improvment
this practice would be more accurate when there is really more captured points during draw, also the Trace-Bitmap must be like this (above image), not a Dashed (smoothed, styled, ...) Line, however you can use this trace bitmap in background (invisible) and only present a dashed copy of that with a colorful background (like grass and rock textures or any graphical improves) to players.
Note
also define a maximum search size if you need more speed for validating draw. this maximum will be used to ignoring some points, for example if max=5 and we have 10 points, 0,2,4,6,8 can be ignored

Smoothest way to render large matrices to canvas element

I have created a dot matrix slider on a canvas element (much like the sort you get in the stock exchange). Currently I have each letter laid out as an individual matrix and then, through a succession of loops I have these letter converted into one large matrix.
I then go through and draw this matrix column by column up to a maximum amount of columns. The matrix then gets redrawn every X milliseconds, offsetting the viewable area of the matrix by one each iteration until it eventually loops. The large matrix doesn't get redrawn every time.
My issue is that the animation doesn't seem smooth at lower redraw intervals - it jumps about. I've checked the frame rate and it seems fine but occasionally it jumps and I can't work out why!
The function with the settings is right at the bottom of the JSFiddle.
dotMatrix({
animationDelay: 1000,
canvasSelector: '#dot-matrix',
dotRadius: 2,
loop: true
});
Here are some steps you could do:
Prerender each char to an off-screen canvas in a solid color on transparent background. This canvas will be used as a sprite-sheet later. Drawing a rounded rectangle is a relative expensive operation especially when you need x number of it per char.
Set up a gradient for the colors and store that too in an off-screen canvas (by now we can see memory-caching is coming to the rescue..).
Every time you update use requestAnimationFrame instead of setInterval. The latter is not able to synchronize to monitor update. Scroll delay can be calculated using the number of frames elapsed as well as the time since last update (see rAF doc for details).
For each update clear, then "blit" the letter from the sprite-sheet canvas to main canvas. When all are blitted change composite mode to source-atop and blit the gradient canvas on top, and reset composite mode to source-over (don't use save/restore - they are expensive).
In the last step you could also use composite mode copy instead of clearing canvas and using source-over, as that will remove any previous existing pixels for the area you draw to.
Hope this gives you some inputs to improve the performance.

D3 JSON paths and SVGs

After some wrestling, I have managed to put together a JSON file that can draw me a map of London and its boroughs. It's here http://graphitti.org/admin2/files/experiments/03_scaledTM5.html
Apart from the fact that the boundaries aren't perfect, the map seems OK but there's a problem in that some, but not all, of the paths apparently take up the whole SVG space. So when I inspect them in the DOM, I end up selecting the whole area. Likewise if I were to colour them in with a fill, I'd turn the whole space that colour.
I've noticed that this tends to happen with the larger boroughs, and the smaller ones are selectable through the DOM. That's not always true, but is there some limit to the number of coordinates that D3 can handle here? Or is there something else up with the code?
the JSON is here http://www.graphitti.org/admin2/files/experiments/EWNI2.json if anyone wants to inspect it. City of London is a "good" borough, as are Hackney and Tower Hamlets. Most of the others, eg Barnet, Barking, are "bad" in that they fill the SVG.
Some of your paths are "inside-out" as far as the d3 mapping functions are concerned. The order of points in a path or sub-path has to be clockwise for it to get mapped properly.
Counter-clockwise loops are interpretted as "holes" within a larger shape, the bounds of which are assumed to be outside the map. As a result, when you colour in the shape, everything except the area within the path gets coloured.
The docs recommend running your GeoJSON file through this utility to re-order the vertices in the correct structure. Of course, you could also write your own utility to reverse the order, and just manually go through and figure out which ones are incorrect.

change rectangle size according to the data in Prefuse

I want to visualize a scatter plot using Prefuse. The difference from typical scatter plot is here I want to use rectangle instead of circle or point. And the reason is I want to visualize the time and duration at the same time. Does anyone know how to set rectangle's length or width according to data in the table? I haven't got the right answer after searching the web.
I initially wants to draw rectangle using this parameter.
ShapeAction shape = new ShapeAction(group, Constants.SHAPE_RECTANGLE);
But I didn't find the way to change only the length of it but to change the whole size. Could anyone give me some instructions? Thanks.
Assuming you want to create a visualization similar to LifeLines or a GANTT chart.
To achive this, prefuse has to be extended prefuse on several points. Here is an outline:
Add a field to the VisualTable to store the x coordinate at the end of the rectangle
Extend AxisLayout to determine the additionally the end of the rectangle.
Extend AbstractShapeRenderer draw a rectangle using the end coordinate

Trying to convert openGL to MFC coordinates and having Problems with "gluProject"

To clarify things, what i am trying to do is to get the openGL coordinates and manipulate them in my mfc code. not to get an openGL object. i'm using the mfc to control the position of the objects in the openGL.
Hi, i'm trying to find the naswer on the web and can't find a full solution that i can use and that will work...
I'm developing a MFC project with static picture as the canvas for an openGL class that draw the grphics for my game.
On moush down, i need to retrive a shape coordinate from the openGL class.
I'm looking for a way to convert the openGL coordinates to MFC coordinates but no matter what i try i get junk after using the gluProject or gluUnProject (i've tried to do both ways but non is working)
GLdouble modelMatrix[16];
glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix);
GLdouble projMatrix[16];
glGetDoublev(GL_PROJECTION_MATRIX,projMatrix);
int viewport[4];
glGetIntegerv(GL_VIEWPORT,viewport);
POINT mouse; // Stores The X And Y Coords For The Current Mouse Position
GetCursorPos(&mouse); // Gets The Current Cursor Coordinates (Mouse Coordinates)
ScreenToClient(hWnd, &mouse);
GLdouble winX, winY, winZ; // Holds Our X, Y and Z Coordinates
winX; = (float)point.x; // Holds The Mouse X Coordinate
winY; = (float)point.y; // Holds The Mouse Y Coordinate
winY = (float)viewport[3] - winY;
glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ);
GLdouble posX=s1->getPosX(), posY=s1->getPosY(), posZ=s1->getPosZ(); // Hold The Final Values
gluUnProject( winX, winY, winZ, modelMatrix, projMatrix, viewport, &posX, &posY, &posZ);
gluProject(posX, posY, posZ, modelMatrix, projMatrix, viewport, &winX, &winY, &winZ);
This is just part of the code i've tried. ofcourse not gluProject and gluUnProject together. just had them both here to show.....and i know there is lots of junk over there, its from some of my tries...
p.s. i've tried many many more combinations and examples from the web and nothing seem to work in my case....
Can any one show me what is the right way to do the transformation?
10x
It looks like you're trying to retrieve the object (or objects) that is/are at a particular point. If this is the case, gluProject and/or gluUnProject isn't really a very suitable tool for the task. OpenGL has a selection mode intended specifically for this kind of task.
In typical use, you specify a small square (e.g., 5x5 pixels) around the mouse click spot with gluPickMatrix, set selection mode with glRenderMode, set a buffer with glSwelectBuffer, and then draw your scene. The drawing doesn't go to the screen, but fills the buffer you specified wiyh records of what was drawn within the specified area.