Here is the code for adding Tribe Vertex
let addTribe = g.addV('tribe')
addTribe.property('tname', addTribeInput.tribename)
addTribe.property('tribeadmin', addTribeInput.tribeadmin)
const newTribe = await addTribe.next()
and Here is the code for adding Edges
const addMember = await
g.V(addTribeInput.tribeadmin).addE('member').
to(g.V(newTribe.value.id)).next()
Is this is a correct way of adding edges?
I am just confusing what should I need to pass in .to() methoud
Gremlin is meant to be chained, so unless you have an explicit reason to break things up, it's much nicer to just do:
g.addV('tribe').
property('tname', addTribeInput.tribename).
property('tribeadmin', addTribeInput.tribeadmin).as('x').
V(newTribe.value.id).as('y').
addE('member').
from('x').
to('y')
Given your variable names I'm not completely sure that I'm doing what you want exactly (e.g. getting the edge direction right), but the point here is that for adding edges you just need to specify the direction of the edge "from" one vertex (i.e. the starting vertex) "to" another vertex (i.e. the ending vertex).
Related
I am analysing solar farms and have defined two areas of geometry. In the example below, for a site called 'Stateline', I have drawn the boundary of the site and saved the geometry as a variable 'Stateline_boundary'. I have drawn around the solar panels within the boundary, which exist in two distinct groups and saved the geometry as a variable 'Stateline_panels'.
Stateline_panels has two co-ordinate lists (as there are two areas of panels).
When I try to subtract the area covered by the panels from the area within the boundary only the first of the two lists in the 'Stateline_panels' geometry is used (see code below and attached image).
var mask = Stateline_boundary
var mask_no_panels = mask.difference(Stateline_panels);
Map.addLayer(mask_no_panels,{},'Stateline_mask_no_panels',false);
I don't understand the behaviour of the geometry. Specifically why when adding the 'Stateline_panels' geometry to the map it displays in its entirety, but when used as a mask breaks the geometry and only uses the first of two lists of coordinates.
I was going to write a longer question asking why the geometry variables seem to behave differently when they are imported into the script rather than listed within the script (which I don't think should make a difference, but it does). However I think this is an earlier manifestation of whatever is going on.
The methodology that I found worked in the end was to create geometry assets individually with the polygon tool in the Earth Engine IDE - ensuring that each is on a different layer (using the line tool, then converting to polygons never worked).
Not only was this more flexible, it was also easier to manage on Earth Engine as editing geometries is not easy. I read about the importance of winding clockwise - though never determined if that was part of the issue here. If I always drew polygons clockwise the issue never occured.
I ended up with my aoi covered in polygons like this (each colour a different named layer/geometry object):
Once this was done, manipulating each geometry object in the code editor was relatively straightforward. They can be converted to FeatureCollections and merged (or subtracted) using simple code - see below for my final code.
It was also then easy to share them between scripts by importing the generated code.
I hope that helps someone - first attempt at answering a question (even if its my own). :)
// Convert panel geometries to Feature Collections and merge to create one object.
var spw = ee.FeatureCollection(stateline_panels_west);
var spe = ee.FeatureCollection(stateline_panels_east);
var stateline_panels = spw.merge(spe);
// Convert 'features to mask' geometries to Feature Collections.
var gc = ee.FeatureCollection(golf_course);
var sp = ee.FeatureCollection(salt_pan);
var sc = ee.FeatureCollection(solar_concentrator);
var h1 = ee.FeatureCollection(hill_1);
var h2 = ee.FeatureCollection(hill_2);
var h3 = ee.FeatureCollection(hill_3);
var mf = ee.FeatureCollection(misc_features);
// Merge geometries to create mask
var features_to_mask = gc.merge(sp).merge(sc).merge(h1).merge(h2).merge(h3).merge(mf);
// Convert 'Features_to_mask' to geometry (needed to create mask)
var features_to_mask = features_to_mask.geometry();
// Change name
var mask = features_to_mask
///// If site has other solar panels nearby need to add these separately & buffer by 1km
var extra_mask = ee.Feature(solar_concentrator);
var extra_mask = extra_mask.buffer(1000);
var extra_mask = extra_mask.geometry();
///// Join mask & extra mask into single feature using .union()
// Geometry objects
var mask = mask.union(extra_mask);
I'm interested in using traversals to quickly find all the documents linked to an initial document. For this I'd use:
let id = 'documents/18787898'
for d in documents
filter d._id == id
for i in 1..1 any d edges
return i
This generally provides me with all the documents related to the initial ones. However, say that in these edges I have more information than just the standard _from and _to. Say it also contains order, in which I indicate the order in which something is to be displayed. Is there a way to also grab that information at the same time as making the traversal? Or do I now have to make a completely separate query for that information?
You are very close, but your graph traversal is slightly incorrect.
The way I read the documentation, it shows that you can return vertex, edge, and path objects in a traversal:
FOR vertex[, edge[, path]]
IN [min[..max]]
OUTBOUND|INBOUND|ANY startVertex
edgeCollection1, ..., edgeCollectionN
I suggest adding the edge variable e to your FOR statement, and you do not need to find document/vertex matches first (given than id is a single string), so the FOR/FILTER pair can be eliminated:
LET id = 'documents/18787898'
FOR v, e IN 1 ANY id edges
RETURN e
How can I get the label of an equation? I'm attempting to reprocess an equation with a label, but I have to delete the label from MathJax.Extension["TeX/AMSmath"].labels first, for which the label must be known...
I know I can scan through the source text for the label MathJax.Hub.getAllJax("mathDiv")[0}.SourceElement().find("\label(") (...), but this seems needlessly complicated. Is there a better way?
There's no built-in API for this.
If you don't need to keep labels, then the reset in the comment above is probably the best way to go about it:
MathJax.Extension["TeX/AMSmath"].labels = {}
A quick and dirty way to get the IDs is to leverage the fact that they end up in the output. So you can just get all the IDs in the output, e.g.,
const math = MathJax.Hub.getAllJax()[0];
const nodesWithIds = document.getElementById(math.root.inputID).previousSibling.querySelectorAll('[id]');
const ids = [];
for (node of nodesWithIds) ids.push(node.id);
A cleaner and perhaps conceptually easier way would be to leverage MathML (which is essentially the internal format): the \label{} always ends up on an mlabeledtr. The trouble is that you'd have to re-parse that, e.g.,
const temp = document.createElement('span');
temp.innerHTML = math.root.toMathML();
const nodesWithIds = temp.querySelectorAll('mlabeledtr [id]');
const ids = [];
for (node of nodesWithIds) ids.push(node.id);
This will make sure the array only has relevant IDs in them (and the contents of the nodes should correspond to \label{}.
I suppose with helper libraries it might be easier to dive into the math.root object directly and look for IDs recursively (in its data key).
I've been struggling with this issue off and on for the better part of a year.
As the title says, i wish to dimension from one side of a wall, to both sides of openings (door openings), then terminate at the other end of the wall (vertically and horizontally). I also wish to dimension to all families hosted in the wall, but i have been able to accomplish this using ScottWilson's voodo magic helper class. Found Here: http://thebuildingcoder.typepad.com/blog/2016/04/stable-reference-string-magic-voodoo.html
foreach (ElementId ele in selSet) {
FamilyInstance fi = doc.GetElement(ele) as FamilyInstance;
Reference reference = ScottWilsonVoodooMagic.GetSpecialFamilyReference(fi,ScottWilsonVoodooMagic.SpecialReferenceType.CenterLR,doc);
refs.Append(reference);
pts[i] = ( fi.Location as LocationPoint ).Point;
i++;
}
XYZ offset = new XYZ(0,0,4);
Line line = Line.CreateBound( pts[0]+offset, pts[selSet.Count - 1]+offset );
using( Transaction t = new Transaction( doc ) )
{
t.Start( "dimension embeds" );
Dimension dim = doc.Create.NewDimension(doc.ActiveView, line, refs );
t.Commit();
}
The problem lies in determining the appropriate stable references to the wall faces. I am able to find all faces on a wall, but this gives me 100+ faces to sort through.
If anyone can help me it would be greatly appreciated!
Side note: The closest of gotten is using a casting a ray trace through my panel, then using a reference intersector method to determine references. But i'm really struggling with implementation: http://thebuildingcoder.typepad.com/blog/2015/12/retrieving-wall-openings-and-sorting-points.html
These two posts should provide more than enough to solve all your issues:
Dimension walls by iterating their faces
Dimension walls by shooting a ray
Basically, you need to obtain references to the faces or edges that you wish to attach the dimensioning to. These references can be obtained in several ways. Two common and easy approaches are:
Retrieve the element geometry using the option ComputeReferences set to true and extract the specific face required.
Shoot a ray through the model to determine the required element and its face using the 2017
ReferenceIntersector Class.
I am testing ArangoDb for using the graph features provided by the framework.
I am trying to create a very simple graph like below, similar to the Java driver example provided here, https://github.com/arangodb/arangodb-java-driver/
List<EdgeDefinitionEntity> edgeDefinitions = new ArrayList<EdgeDefinitionEntity>();
EdgeDefinitionEntity edgeDefinition = new EdgeDefinitionEntity();
edgeDefinition.setCollection("myEdgeCollection");
List<String> from = new ArrayList<String>();
from.add("myCollection1");
edgeDefinition.setFrom(from);
List<String> to = new ArrayList<String>();
to.add("myCollection2");
edgeDefinition.setTo(to);
edgeDefinitions.add(edgeDefinition);
GraphEntity graph = arangoDriver.createGraph("myGraph",
edgeDefinitions, null, true);
User myObject1 = new User("Homer", 38);
User myObject2 = new User("Bart", 36);
User myObject3 = new User("Marge", 39);
User myObject4 = new User("Lisa", 40);
DocumentEntity<User> vertexFrom1 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection1", myObject1, true);
DocumentEntity<User> vertexFrom2 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection1", myObject2, true);
DocumentEntity<User> vertexTo1 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection2", myObject3, true);
DocumentEntity<User> vertexTo2 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection2", myObject4, true);
EdgeEntity<?> edge1 = arangoDriver.graphCreateEdge("myGraph",
"myEdgeCollection", null, vertexFrom1.getDocumentHandle(),
vertexTo1.getDocumentHandle(), null, null);
EdgeEntity<?> edge2 = arangoDriver.graphCreateEdge("myGraph",
"myEdgeCollection", null, vertexFrom2.getDocumentHandle(),
vertexTo2.getDocumentHandle(), null, null);
The edge collection seems to have a right mapping,
{"_from":"myCollection1/1544266710","_to":"myCollection2/1544987606"}
{"_from":"myCollection1/1544528854","_to":"myCollection2/1545249750"}
I am trying to visualise this graph in the web interface. Graph visualization is showing some weird behaviour which I do not understand. In the above setup, I expect four nodes in the graph with edges between "Homer" -- "Marge" and "Bart" -- "Lisa" but I see only two nodes and one edge, i.e. Homer -- Marge.
Visulaization view itself sometimes shows that there are no nodes and on revisit to the same page nodes appear.
The graph viewer starts with a random vertex. That means it probably uses a totally different start vertex whenever it's opened.
This is because a graph in the general case can contain many vertices and displaying all of them together is not an option because it may take a long time to render or even crash the browser. Which vertex to put into the center of the display at start is also not really easy to determine because this would require the graph viewer to know which vertex is more important than others or most important to the users. As it doesn't know that, there is the random start vertex selection.
You can select a different start/center vertex by clicking on the filter icon in the top right of the graph viewer. This will bring up a search input field that you can use to select a start vertex by any attribute (e.g. name == Homer if your vertices contain a name attribute).
If such vertex exists, it will be put into the center of the screen, along with all its directly connected vertices. Note that only relationships/edges from the start vertex to its directly connected vertices will be shown. Indirect connections will not be shown in the graph viewer by default. Clicking on any of the vertices displayed will expand (or contract) them and may bring up further relationships.
Again all of this is done because it may not be possible to display the entire graph at start (imagine a graph with a few million nodes). But as your question indicates, the current solution may not be intuitive.