{"id":1631,"date":"2018-06-28T15:06:35","date_gmt":"2018-06-28T15:06:35","guid":{"rendered":"https:\/\/wetransform.eu\/?post_type=news-and-events&#038;p=1631"},"modified":"2022-07-28T08:40:45","modified_gmt":"2022-07-28T08:40:45","slug":"groovy-complete-network","status":"publish","type":"news-and-events","link":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/","title":{"rendered":"It&#8217;s Groovy Week: Create complete networks with Nodes and Links"},"content":{"rendered":"<p>It's Thursday, or as we at wetransform (thanks to the influence of a certain Venezuelan on the team) call it, <a href=\"http:\/\/www.tubabel.com\/definicion\/86260-juernes\">Juernes<\/a>! <\/p>\n<p>In this fourth installment of the Groovy Scripting week, we will tackle another non-trivial case: Building a complete network with nodes and links when your only input data was a bunch of spaghetti lines. This actually requires three scripts. It also shows in detail how to use priorities and other advanced features.<\/p>\n<p>Like the previous posts, note that this article assumes you have working knowledge of hale studio and know the <a href=\"http:\/\/help.halestudio.org\/latest\/nav\/0_3\">terminology<\/a>.<\/p>\n<h2>Thursday's Script: Create Nodes from Links and build out topology (Simon)<\/h2>\n<p>In many projects, we did not receive a fully consistent set of Nodes and Links from customers to create a complete Network, or there were no Nodes available at all.<\/p>\n<p>These three snippets extract the first and last Coordinates from each Link (LineString\/Curve) and then set up the Node objects, and then create bidirectional references.<\/p>\n<h3>Collect Nodes and connected Segment IDs<\/h3>\n<p>This is a simple Groovy Retype function that uses the links as a source. The target does not matter, since no target objects are emitted. In this example, the segments are called <code>vaarwegvakken<\/code>, and the IDs of these segments are stored in the field <code>vwk_id<\/code>. This function needs to be executed first and should thus have the highest execution priority.<\/p>\n<p>This is the full script:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JBoudewijn\/01010d159fc536067b7805974e63b51a.js\"><\/script><\/p>\n<p>You can download this script <a href=\"https:\/\/github.com\/wetransform-os\/website-examples\/blob\/af7108ee8f5a838327c3e4b871850212c399e37c\/news\/resources\/nodesFromLinks_1_collect.groovy\">here<\/a>.<\/p>\n<h2>Create the Nodes objects with references to the links<\/h2>\n<p>This snippet is used in a Groovy Create function that has the Node type as a target. This function has to be executed second and needs to have the higher execution priority.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JBoudewijn\/a37d235334e5ccd41e37cc78ba95a51f.js\"><\/script><\/p>\n<p>This script also shows how to create a geometry from a coordinate, using a specific coordinate Reference system.<\/p>\n<p>You can download the script <a href=\"https:\/\/github.com\/wetransform-os\/website-examples\/blob\/af7108ee8f5a838327c3e4b871850212c399e37c\/news\/resources\/nodesFromLinks_2_create.groovy\">here<\/a>.<\/p>\n<h3>Add References from Links to Nodes to the Links<\/h3>\n<p>In the final step, we add the references from the Links to the nodes created before, so that we have a fully navigable graph in the transport network. This script is inside a normal Groovy Function that has the domain ID of source as the source property and either the startNode or endNode property of the Link as the target property. The surrounding type transformation needs to have a normal execution priority so that it runs after the two other functions.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/JBoudewijn\/927ffe7e6cd52d293f9fb6843bf18189.js\"><\/script><\/p>\n<p>You can download this script <a href=\"https:\/\/github.com\/wetransform-os\/website-examples\/blob\/af7108ee8f5a838327c3e4b871850212c399e37c\/news\/resources\/nodesFromLinks_3_reference.groovy\">here<\/a>.<\/p>\n<p>Happy transforming!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s Thursday, or as we at wetransform (thanks to the influence of a certain Venezuelan on the team) call it, Juernes! In this fourth installment of the Groovy Scripting week, we will tackle another non-trivial case: Building a complete network with nodes and links when your only input data was a bunch of spaghetti lines. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[48],"tags":[47,21,46],"class_list":["post-1631","news-and-events","type-news-and-events","status-publish","hentry","category-tutorials","tag-groovy","tag-halestudio","tag-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.1 (Yoast SEO v28.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>It&#039;s Groovy Week: Create complete networks with Nodes and Links - wetransform<\/title>\n<meta name=\"description\" content=\"Build a complete network with nodes and links when your only input data is a bunch of spaghetti lines, using Groovy script in hale\u00bbstudio!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"It&#039;s Groovy Week: Create complete networks with Nodes and Links\" \/>\n<meta property=\"og:description\" content=\"Build a complete network with nodes and links when your only input data is a bunch of spaghetti lines, using Groovy script in hale\u00bbstudio!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/\" \/>\n<meta property=\"og:site_name\" content=\"wetransform\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-28T08:40:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/04\/logo-large-e1657284415170.png\" \/>\n\t<meta property=\"og:image:width\" content=\"254\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wetransformto\" \/>\n<meta name=\"twitter:label1\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data1\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/groovy-complete-network\\\/\",\"url\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/groovy-complete-network\\\/\",\"name\":\"It's Groovy Week: Create complete networks with Nodes and Links - wetransform\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#website\"},\"datePublished\":\"2018-06-28T15:06:35+00:00\",\"dateModified\":\"2022-07-28T08:40:45+00:00\",\"description\":\"Build a complete network with nodes and links when your only input data is a bunch of spaghetti lines, using Groovy script in hale\u00bbstudio!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/groovy-complete-network\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/groovy-complete-network\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/groovy-complete-network\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/wetransform.to\\\/de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"News & Events\",\"item\":\"https:\\\/\\\/wetransform.to\\\/de\\\/news-and-events\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"It&#8217;s Groovy Week: Create complete networks with Nodes and Links\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#website\",\"url\":\"http:\\\/\\\/wetransform.to\\\/de\\\/\",\"name\":\"wetransform\",\"description\":\"Making environmental data useful and accessible\",\"publisher\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/wetransform.to\\\/de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Organization\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#organization\",\"name\":\"wetransform\",\"url\":\"http:\\\/\\\/wetransform.to\\\/de\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/wetransform.to\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/large-logo-whitebg.png\",\"contentUrl\":\"https:\\\/\\\/wetransform.to\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/large-logo-whitebg.png\",\"width\":1024,\"height\":1024,\"caption\":\"wetransform\"},\"image\":{\"@id\":\"http:\\\/\\\/wetransform.to\\\/de\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/wetransformto\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/wetransform-gmbh\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"It's Groovy Week: Create complete networks with Nodes and Links - wetransform","description":"Build a complete network with nodes and links when your only input data is a bunch of spaghetti lines, using Groovy script in hale\u00bbstudio!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/","og_locale":"de_DE","og_type":"article","og_title":"It's Groovy Week: Create complete networks with Nodes and Links","og_description":"Build a complete network with nodes and links when your only input data is a bunch of spaghetti lines, using Groovy script in hale\u00bbstudio!","og_url":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/","og_site_name":"wetransform","article_modified_time":"2022-07-28T08:40:45+00:00","og_image":[{"width":254,"height":200,"url":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/04\/logo-large-e1657284415170.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@wetransformto","twitter_misc":{"Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/","url":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/","name":"It's Groovy Week: Create complete networks with Nodes and Links - wetransform","isPartOf":{"@id":"http:\/\/wetransform.to\/de\/#website"},"datePublished":"2018-06-28T15:06:35+00:00","dateModified":"2022-07-28T08:40:45+00:00","description":"Build a complete network with nodes and links when your only input data is a bunch of spaghetti lines, using Groovy script in hale\u00bbstudio!","breadcrumb":{"@id":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wetransform.to\/de\/news-and-events\/groovy-complete-network\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wetransform.to\/de\/"},{"@type":"ListItem","position":2,"name":"News & Events","item":"https:\/\/wetransform.to\/de\/news-and-events\/"},{"@type":"ListItem","position":3,"name":"It&#8217;s Groovy Week: Create complete networks with Nodes and Links"}]},{"@type":"WebSite","@id":"http:\/\/wetransform.to\/de\/#website","url":"http:\/\/wetransform.to\/de\/","name":"wetransform","description":"Making environmental data useful and accessible","publisher":{"@id":"http:\/\/wetransform.to\/de\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/wetransform.to\/de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"http:\/\/wetransform.to\/de\/#organization","name":"wetransform","url":"http:\/\/wetransform.to\/de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"http:\/\/wetransform.to\/de\/#\/schema\/logo\/image\/","url":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/07\/large-logo-whitebg.png","contentUrl":"https:\/\/wetransform.to\/wp-content\/uploads\/2022\/07\/large-logo-whitebg.png","width":1024,"height":1024,"caption":"wetransform"},"image":{"@id":"http:\/\/wetransform.to\/de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/wetransformto","https:\/\/www.linkedin.com\/company\/wetransform-gmbh\/"]}]}},"_links":{"self":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events"}],"about":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/types\/news-and-events"}],"author":[{"embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/comments?post=1631"}],"version-history":[{"count":3,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1631\/revisions"}],"predecessor-version":[{"id":3771,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/news-and-events\/1631\/revisions\/3771"}],"wp:attachment":[{"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/media?parent=1631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/categories?post=1631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wetransform.to\/de\/wp-json\/wp\/v2\/tags?post=1631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}