• Skip to main content
  • Skip to footer

INT

Empowering Visualization

CONTACT US SUPPORT
MENUMENU
  • Products
    • Overview
    • IVAAP™
    • INTViewer™
    • GeoToolkit™
    • Product Overview
  • Demos
    • GeoToolkit Demos
    • IVAAP Demos
  • Success Stories
  • Solutions
    • Overview
    • For E&P
    • For OSDU Visualization
    • For Cloud Partners
    • For Machine Learning
    • For CCUS
    • For Geothermal Energy
    • For Wind Energy
    • For Enterprise
    • Tools for Developers
    • Services Overview
  • Resources
    • Blog
    • Developer Community
    • FAQ
    • INT Resources Library
  • About
    • Overview
    • News
    • Events
    • Careers
    • Meet Our Team
    • About INT

GeoToolkit

May 15 2019

5 Simple Techniques to Avoid Bugs While Programming

Programming is an activity that requires a special set of cognitive skills. While the industry has developed processes and tools to ensure the quality of software artifacts, the act of writing code is a craft in itself. Developers pride themselves on the “big picture” results they achieve, but the activity of programming is definitely a humbling experience: It’s easy to introduce bugs, and regardless of whether I catch them right away or later in the pipeline, I hate to be reminded I am inherently flawed and have introduced a defect. For this article, I will focus on simple methods to avoid bugs, not before or after you write code, but while you write that code.

Leverage the Hints from the IDE

This one should be obvious to most programmers, but the reality is that the tools we use are a bit smarter than what we give them credit for. It’s easy to miss these hints. They are sometimes buried in build logs, drowned in a sea of flags, visually too subtle to attract our much-needed attention. Listen to your Integrated Development Environment (IDE)—it is telling you something.

One of the most obvious signs that something is up with your code is when the IDE tells you that you are not using a variable you introduced earlier in your code. You had some intent for this variable, but that intent got lost while working on some other aspect. There is certainly a bug lurking there.

Another useful alert is when the IDE detects that there is a logical path for a NullPointerException. Maybe the most common case is well taken care of, but there seems to be a road less-travelled to this ubiquitous exception.

The activity of writing code forces you to concentrate on the text you are typing while keeping a stack of other concerns in mind. This cognitive load is already heavy; I like to reduce it by removing ambiguities. The IDE will tell you when you are using the same variable name for an instance variable and a local variable. I don’t need to risk being confused about which one I am manipulating. I’ll follow my digital assistant’s advice and rename the local variable in question.

Break up Your Content

The brain can only keep so much information. And each coding window only shows you about 50 lines. When the code grows, so does the likelihood of bugs, just from not remembering details implemented a few invisible lines away. One simple technique to avoid such troubles is to break up the code. Keep the methods short. Ideally, a well-focused class shouldn’t have more than 200 lines. It’s not always possible, but where it is, you can avoid bugs when each class has only one responsibility. The class’ code itself is easy to review, and its function is easy to remember in other contexts. If you just wrote a large body of code in one class, it’s time to break it up into smaller pieces.

This is nothing new. When the metric of cyclomatic complexity was developed in 1976, its first applications tried to limit the complexity of each module, splitting them into smaller modules. These modules became easier to write, and easier to test, too. If the most likely place for defects is where complexity lies, reducing complexity automatically reduces the rate of defects.

It’s not just the height of your screen that matters when having “too much to code” might be “too much to cope.” The width matters, too. This is actually a classic source of bugs: a line goes beyond what’s visible without scrolling, meaning it’s not being looked at as often as other lines. Code reviewed less is more likely to be incorrect. Long lines are also bug candidates when overly confident IDEs autofill their content over the developer’s watchful eyes. The simple solution is to break up these long lines, for example, inserting carriage returns when they go over 120 characters. The IDE will often show you this limit graphically.

Use the Java Type System

Object-oriented programming is a great way to abstract sequential instructions into relationships and behaviors. The Java type system is quite powerful. When two pieces of code interact, the parameters of this interaction typically need to meet specific type requirements, so the compiler will prevent code being typed from using the wrong object type in the wrong context.

You can use this type checking to your advantage to reduce opportunities for bugs. Writing a program often requires code where mundane objects are being passed around—a collection of names, an Integer identifying a record, etc. If you inadvertently pass the wrong list of Strings, the compiler won’t be any help. Instead of passing List<String> or Integer, create your own objects, such as “NamesCollection” and “RecordId.” By forcing the passing of functional objects instead of generic ones, you will know immediately, as you type, that you just picked up the wrong collection or the wrong number.

Don’t Leave Your Code to Chance

I have seen many cases where two (or more) classes have the exact same name. They have different package names, but package names are hidden away at the very beginning of each class that uses another class. It’s a good idea to give classes unique names across your code base. This will make sure there is no ambiguity around which one a developer is using. Murphy’s law is not your friend—you will inevitably pick the wrong one otherwise.

The behavior of HashMaps may also be a source of hard-to-troubleshoot bugs. The Java Virtual Machine tends to optimize the behavior of HashMaps when the application load grows. What this means for developers is that you will observe one behavior during development, and a different behavior in production. To avoid this kind of head-scratching riddle, I have learned to use LinkedHashMaps even when not needed as they will always return entries in a consistent manner. This is a trick to use wisely: the performance cost of using LinkedHashMaps should be weighed against the risk of having to solve a problem that only happens in production.

Reuse Existing Code

At the end of the day, there is so much to keep track of, just writing code is doomed to produce bugs. The simplest way to avoid writing bugs is not write any code at all, and leverage some other battle-tested component instead.

Reusing code is the ultimate simplification technique, but I am not just talking about integrating other people’s work into your own software. The code you already have is the result of many refactorings. It has real-world experience you are missing (or that you forgot). Use the code you already have as your template. If the quality of your template is not what you need, refactor this code, then reuse it. There shouldn’t be in your program “two best patterns” to do the same thing.

As I implement a new feature, I typically look at similar code doing similar things: how classes, methods, and variables are (meaningfully) named, which properties and behaviors are exposed, how objects interact with each other, etc. In all the bodies of code I have maintained for several years, I have found that consistency is the easiest constraint to follow, to teach, and the one that brings the most benefits in terms of overall quality.

Filed Under: GeoToolkit, HTML5Viewer, INTViewer, IVAAP Tagged With: developing, IDE, java, programming

Apr 15 2019

TotalEnergies to Use INT’s Data Visualization and Analysis Platform and Libraries Software for the Next Five Years

TotalEnergies and INT have recently announced a long-term corporate agreement that will give TotalEnergies access to INT’s GeoToolkit, the most widely adopted JavaScript-based data visualization technology software in Oil and Gas.

TotalEnergies will also be able to take advantage of IVAAP, one of the leading Data Visualization software platforms for digital subsurface projects deployed in the web or private cloud.

“With the growth of Big Data and IoT, the E&P industry needed a solution that would empower companies to combine and utilize vast amounts of incredibly useful, yet disparate domain data easily, in one powerful software,” said Dr. Olivier Lhemann, founder and CEO, Interactive Network Technologies.

“Fortunately, our unique expertise and position in the industry allowed us to recognize and respond to this need quickly, so we developed IVAAP. Now, we’re proud to partner with TotalEnergies to empower domain experts with the right digital tools they need to gain valuable, timely insights from their data.”

With this agreement, TotalEnergies Exploration & Production will gain access to GeoToolkit and IVAAP’s fully extensible platform, cloud-based architecture, and comprehensive set of data connectors to current systems such as WITSML, PPDM, OSIsoft, PI, and many others.

For more information on INT’s products and services, visit our products page or email us to discuss how we can help you visualize your upstream data.

View the press release

Learn more about INT’s products

 

Filed Under: GeoToolkit, Uncategorized Tagged With: geotoolkit, ivaap, TotalEnergies

Feb 15 2018

How to Add Overlay to Visualize Data from ArсGIS Feature Service

GeoToolkit.JS provides a set of libraries that display seismic, log, schematic, contour, real-time data, and more, and it includes a lightweight widget to display geographical data as layers from web map tile services (WMTS) like Google Map, OpenStreetMap, ESRI, MapQuest, and others and vector data from web map feature services (WFS).

WFS services can provide data in popular formats such as GeoJSON and ArcGIS ESRI Feature Layer format, KML. In this post, we consider how to display data, which includes geometry and nonspatial information like names, from ArcGIS ESRI services using the GeoToolkit.JS Map Widget and WMTS data from OpenStreetMap. The release of GeoToolkit.JS 2.5 is a good opportunity to tour basic map options.

First, we need to have the latest version of the GeoToolkit.JS library in our system. We will use Angular framework and TypeScript to be more realistic to real-world web application. Also Angular CLI is used to simplify creation of this application. The following screenshot demonstrates a simple map application with three layers: WMTS with world map, ArcGIS Feature layer of states, and ArcGIS Feature layer of U.S. counties from public service.

Single map application

The full source code of this example can be found here on Github.

Let’s start writing application. If general initialization of Angular application is not relevant to you, then start with section 3.

Install the Necessary Software

This step can be skipped if you have Angular-cli and node.js on your computer.

Verify that you have node.js and npm in your system using the following command in console:

node -v

If installation does not exist, then go here and install the last LTS distribution.

The next step is to install the last version of Angular-cli in your system.

npm install -g @angular/cli

Create the Application

We start creation of the application using Angular-cli commands ng new

ng new ArgGISOverlay
cd ArgGISOverlay
ng serve

If it works, then create a folder called ArcGISOverlay\src\libs\geotoolkit and copy all files from the bin folder of GeoToolkit.JS installation.

Add a section in the .angular-cli.json file

“scripts”: [
“libs/geotoolkit/geotoolkit.adv.js”,
“libs/geotoolkit/geotoolkit.controls.adv.js”,
“libs/geotoolkit/geotoolkit.svg.adv.js”,
“libs/geotoolkit/geotoolkit.data.adv.js”,
“libs/geotoolkit/geotoolkit.pdf.adv.js”,
“libs/geotoolkit/geotoolkit.widgets.adv.js”,
“libs/geotoolkit/geotoolkit.map.adv.js”
],

Add a new component to display the map. Let’s call it OverlayComponent

ng g component overlay

Add CSS file to define application styles and add to styles.css

Add the following lines to app.component.html

<div class="content">
<app-overlay></app-overlay>
</div>

Add the following lines to overlay-component.html to specify HTML% canvas element to be used to render map. Parent div is used to control size of our map.

<div #parent class='plothost'>
 <canvas #map class='plot' oncontextmenu='return false'></canvas>
</div>

Add Layers

A map widget can support any number of layers. In our example, we add three layers.

The first is the WMTS layer which points to INT OpenStreetMap server.

return new geotoolkit.map.layers.WMTSLayer({
   'server': ['https://demo.int.com/osm_tiles/'],
   'minlod': 0,
   'maxlod': 19,
   'formatterfunction': function (z, x, y) {
     return z + '/' + y + '/' + x + '.png';
   }
 });

Second, add two ArcGIS overlays with data from the public URL of ArcGIS Feature Layer services. A layer initialization to load states looks like:

return new geotoolkit.map.layers.ArcGISFeatureLayer({
    'system': geotoolkit.map.GeodeticSystem.LatLon,
    'idfield': 'state_name',
    'server': service_url     
     });
};

It has three properties: the input coordinate system, unique field id, and server url. The second layer is similar.

If a source has a field, which defines a unique id of the feature, then it can be specified. This information can be found on page with service description. In our case, one layer has id, another doesn’t have it. If id is not specified, then artificial id is assigned for each feature.

In additional to geometry, each feature layer can provide nonspatial attributes. By default, layer loads all attributes for each feature. If you don’t need it, then you can declare them using property requestfields like this requestfields: [‘name’, ‘population]

In the next step, create a map widget and add three layers into it.

let map = new geotoolkit.map.Map({});
map.addLayer(this.createWMTSLayer());
map.addLayer(this.createCountiesLayer());
map.addLayer(this.createStatesLayer());

The last step is to initialize GeoToolkit.JS plot to render map layers on underlying HTML5 Canvas element, and the application is ready.

Customize the Feature Layer

In this section, we show how to change the graphical properties of the loaded Feature Layer. For example, we would like to color counties based on population. We just use one attribute of the counties layer “pop2000”, which represents a population of each county in 2000. A feature in ArcGISFeatureLayer can be rendered with shape template, which can be polygon, polyline, symbol, or any custom representation. For example, pie chart.

As a rule, it has only one instance of template for the sample type of features. In our case, we sort existing features by population and replace shape template, which is responsible for rendering particular features with custom shape with specified attributes. The result of this operation can be seen if you press the “Classify” button on the toolbar of this application. The source code looks like this:

this.countiesLayer.setTemplate(country, template);

We tell the application to use a new template for this feature instance. This application can be optimized if we group features by colors, but we will save that for a future post.

For more information about GeoToolkit, visit the GeoToolkit product page, or contact us for a free trial.


Filed Under: GeoToolkit Tagged With: arcgis, geotoolkit

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3

Footer

Solutions

  • For E&P
  • For OSDU Visualization
  • For Cloud Partners
  • For Machine Learning
  • For CCUS
  • For Geothermal Energy
  • For Wind Energy
  • For Enterprise
  • Tools for Developers
  • Customer Success Stories

Products

  • IVAAP
  • GeoToolkit
  • INTViewer
  • IVAAP Demos
  • GeoToolkit Demos

About

  • News
  • Events
  • Careers
  • Management Team

Resources

  • Blog
  • FAQ

Support

  • JIRA
  • Developer Community

Contact

INT logo
© 1989–2023 Interactive Network Technologies, Inc.
Privacy Policy
  • Careers
  • Contact Us
  • Search

COPYRIGHT © 2023 INTERACTIVE NETWORK TECHNOLOGIES, Inc