I'm trying to build a CQL query in order to find a certain shape in my spartial database.
I want my query return the shape with the biggest intersection. My idea was to set LIMIT=1 and sortBy intersection.
If you see the screenshot attached, I would like my query return the following:
Triangle shapes from left to right
Filter1 --> YELLOW SHAPE
Filter2 --> YELLOW SHAPE
Filter3 --> GREEN SHAPE
Is there any way to solve my problem?
I'am using the following code so far:
Filter f1 = CQL.toFilter("INTERSECTS(the_geom, POLYGON((10.07051 53.23476, 10.08143 53.23512, 10.07596 53.22838, 10.07051 53.23476)))");
Filter f2 = CQL.toFilter("INTERSECTS(the_geom, POLYGON((10.06268 53.23756, 10.06889 53.23865, 10.06260 53.24903, 10.06268 53.23756)))");
Filter f3 = CQL.toFilter("INTERSECTS(the_geom, POLYGON((10.08146 53.24462, 10.09540 53.24761, 10.08247 53.26067, 10.08146 53.24462)))");
Query query = new Query( typeName, f3);
query.setMaxFeatures(1);
source.getFeatures(query);
SimpleFeatureCollection features = source.getFeatures(query);
SimpleFeatureIterator it = features.features();
while (it.hasNext()){
SimpleFeature sf = it.next();
System.out.println(sf.getAttributes());
}
See the screenshot here
Related
I'm working on a project on 8th Wall using A-Frame and Three.js.
I'm using a component called "text-geometry" which generates extruded text nicely. But I want the text to be centered, not "flush-left", so I need to move it left by half its rendered width. I'm doing this using a bounding box:
bbox = new THREE.Box3().setFromObject(mesh)
el.object3D.position.x = (bbox.min.x - bbox.max.x) / 2
The problem is that if the text is nested within several levels of a-entities each with its own scale, the centering is incorrect.
So I am crawling up through all nested entities to find the "true scale":
let [trueScale, ee] = [1, el]
while (ee.parentElement) {
const scale = ee.getAttribute('scale')
if (scale) { trueScale *= scale.x }
ee = ee.parentElement
}
This seems inefficient – is there a more elegant way to do this so that my bbox returns the correct width accounting for the 'effective' scale of the text entity?
I want to draw 3d cube in SceneView by interactive operation.
The functions I hope to achieve are:
Click multiple points (x1, y1,0), (x2, y2, 0), (x3, y3, 0), (x4, y4, 0) on SceneView through interaction.
Enter the height h through the pop-up window.
Draw a cube with these points:
(x1,y1,0),(x2,y2,0),(x3,y3,0),(x4,y4,0),(x1,y1,h),(x2,y2,h),(x3 ,y3,h),(x4,y4,h)
I tried this:
var centerPoint = new MapPoint(vm.X, vm.Y, vm.Z, onMapLocation.SpatialReference);
SimpleMarkerSceneSymbol symbol = SimpleMarkerSceneSymbol.CreateCube(System.Drawing.Color.DarkSeaGreen, 1, SceneSymbolAnchorPosition.Center);
symbol.Heading = vm.Heading;
symbol.Height = vm.Height;
symbol.Width = vm.Width;
symbol.Depth = vm.Depth;
// Create the graphic from the geometry and the symbol.
Graphic item = new Graphic(centerPoint, symbol);
// Add the graphic to the overlay.
graphicOverlay.Graphics.Add(item);
It works,but I can only get one point from Geometry. I want to get all vertices of my cube.
Then I tried to draw a polygon without Z , and set Renderer to display:
// Create a new simple line symbol for the feature layer
SimpleLineSymbol mySimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Black, 1);
// Create a new simple fill symbol for the feature layer
SimpleFillSymbol mysimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.WhiteSmoke, mySimpleLineSymbol);
// Create a new simple renderer for the feature layer
SimpleRenderer mySimpleRenderer = new SimpleRenderer(mysimpleFillSymbol);
// Get the scene properties from the simple renderer
RendererSceneProperties myRendererSceneProperties = mySimpleRenderer.SceneProperties;
// Set the extrusion mode for the scene properties
myRendererSceneProperties.ExtrusionMode = ExtrusionMode.AbsoluteHeight;
// Set the initial extrusion expression
myRendererSceneProperties.ExtrusionExpression = "[Z]";
// Set the feature layer's renderer to the define simple renderer
featureLayer.Renderer = mySimpleRenderer;
In my featureLayer, it has a feature Z, so it works.
But this does not meet my requirements, I want to draw the cube in real time instead of reading the data.
I don't know how to achieve...
A .NET solution is the best, and other languages are also acceptable.
Finally, please forgive my poor English :(
Finally, I used Render to solve the problem, but I was not satisfied with this solution.
This is my completed result:
https://www.cnblogs.com/Lulus/p/13948464.html
I am trying to draw svg/pointcloud points on individual elements in Autodesk Forge. How to get (x,y,z) coordinates of elements.
Is there a way to extract positions of individual object so that we have the position vector in world space.
What I tried so far:
I cant seem to understand how to use the positions array as described in this thread using
frags = viewer.impl.getRenderProxy( viewer.model, fragId )
positions = frags.geometry.vb
Autodesk.ADN.Viewing.Extension.MeshData.js gives me the vertices of triangles (meshes/fragments) the element is made of.
I've created a self-contained extension that you can add to your viewer and illustrates how to get the component position:
Check this repo and the TransformationExplorerExtension
The code responsible for extracting the transformation matrix is:
getFragmentWorldMatrixByNodeId(nodeId) {
let result = {
fragId: [],
matrix: [],
};
let viewer = this.viewer;
this.tree.enumNodeFragments(nodeId, function (frag) {
let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
let matrix = new THREE.Matrix4();
fragProxy.getWorldMatrix(matrix);
result.fragId.push(frag);
result.matrix.push(matrix);
});
return result;
}
I am trying to display pushpins on a map but as i have lots of pushpins i only want to display the ones within the viewable area of the map which should hopefully make the map more responsive.
I get my list of x y points from a query to a database.
This is the code I have so far..
List<Pushpin> ListofPoints = new List<Pushpin>();
foreach (var element in query)
{
//Add a pin to the map
Pushpin pushpin = new Pushpin();
Location location = new Location();
location.Latitude = Convert.ToDouble(element.X);
location.Longitude = Convert.ToDouble(element.Y);
pushpin.Location = location;
ListofPoints.Add(pushpin);
map1.Children.Add(pushpin);
}
// Position map based on a collection of Pushpins points
var x = from l in ListofPoints
select l.Location;
map1.SetView(LocationRect.CreateLocationRect(x));
ListofPoints.Clear();
Can anyone give my any advice/code on how to only display the points on the viewable area of map?
Thanks
Use the ViewChangeStart and ViewChangeEnd events to get the current view after the change and then requery your dataset and update the displayed pins as necessary.
I have a simple application which polls database for data every minute. When new data is fetched, I am updating the graph using ajax. However, whenever I update the graph (re-plot it with new values added to plot data) the current state of zoom is lost. Before updating the graph, I want to preserve the latest zoom position. After updating the graph, I want to zoom the graph to its saved position. This is important because re-zooming every minute is irritating. Is this possible?
I tried this answer from Ozan and I couldn't get the block for copying the zoom to work so I just used plot.getOptions() and used that to draw the graph.
Like this:
var oldOptions = plot.getOptions();
plot = $.plot($("#graph"), data, oldOptions);
This way you can dynamically change your view and the auto-update will update without changing your view.
Here is the answer by Joshua Varner 1
When you get your new data before you re plot get the current zoom and
add it to the options on update.
// Get the current zoom
var zoom = plot.getAxes();
// Add the zoom to standard options
var zoomed = {};
$.extend(zoomed,options);
zoomed.xaxis.min = zoom.xaxis.min;
zoomed.xaxis.max = zoom.xaxis.max;
zoomed.yaxis.min = zoom.yaxis.min;
zoomed.yaxis.max = zoom.yaxis.max;
// draw/save the plot
plot = $.plot($("#graph"), d, zoomed);
You should get the information about the state of the current axes, merge it with your initial options and than provide them to the new plot.
// Deep copy of the options object so that we can keep it unchanged
// for when we don't want to preserve the zoom.
var copyOptions = $.extend(true, {}, options);
if (plot != null && preserveZoom) {
// There might be more than one Y axis
var zoomY = plot.getYAxes();
for (var i = 0; i < zoomY.length; i++) {
copyOptions.yaxes[i].min = zoomY[i].min;
copyOptions.yaxes[i].max = zoomY[i].max;
}
// Considering only one X axis, in case of more than one
// you should use the same method as for the Y axis.
copyOptions.xaxis.min = plot.getXAxes()[0].min;
copyOptions.xaxis.max = plot.getXAxes()[0].max;
}
plot = $.plot("#placeholder", data, copyOptions);