Exploring Detailed Map Coordinates with ThreeJS

Attempting to visualize UTM/WGS84 coordinates in three.js, I've encountered a challenge with the fine granularity of trajectories. The movements are so subtle that it's difficult to distinguish any real changes in behavior. I am seeking a method to plot a Space-Time-Cube where X and Y represent space, and Z signifies time. However, I am struggling to project the trajectory data in a way that clearly shows the location changes. While normalizing the data provided some results, I am interested in exploring more sophisticated techniques. My trajectory information is sourced from a CSV file stored in the variable 'data,' containing 1500 tuples with LAT, LON (EPSG 4326), and ascending seconds. The movement data I have reflects an object traversing approximately four football fields.

12.4309352,48.4640973,0
12.4301431,48.4655268,15
12.4288555,48.4658138,30
12.4266812,48.4653488,45
12.4245049,48.4648678,60
12.4228305,48.4639438,75
12.4217859,48.4625038,90
... ... ...

Included below is my code progression along with accompanying comments:

var data = $.csv.toArrays(csv);

var renderer,
scene,
camera,
controls

//terrainSize was an experimental parameter that did not yield significant changes

var terrainSize = 60;

if (!Detector.webgl) Detector.addGetWebGLMessage();
renderer = new THREE.WebGLRenderer({ antialias: true });
document.body.appendChild(renderer.domElement);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColorHex(0xeeeeee, 1.0);

scene = new THREE.Scene();

var material = new THREE.LineBasicMaterial({
  color: 0xff00cc,
  fog: true
});

var geometry = new THREE.Geometry();

var x = []
var y = []
var z = []

var count = 0;
for (var row in data) {
   count += parseInt(data[row][2]); 
   x.push(parseFloat(data[row][0]));
   y.push(parseFloat(data[row][1]));
   z.push(parseFloat(count));
}


//Normalization of seconds for enhanced visibility on the map

z_stretch = stretch_array(z, 10, 1)

function stretch_array(my_stretched_array, given_stretch, multiplier) {
   ratio = Math.max.apply(this, my_stretched_array) / given_stretch,
   l = my_stretched_array.length;

   for (i = 0; i < l; i++) {
      my_stretched_array[i] =  my_stretched_array[i] / ratio;
   }                

   for (i = 0; i < my_stretched_array.length; i++) {
      my_stretched_array[i] = multiplier * my_stretched_array[i];
   }
   return my_stretched_array;
}


//Reformation of the data post-normalization

var data_stretched = []

for (i = 0; i < data.length; i++) {
   data_stretched.push([x[i], y[i], z_stretch[i]]);
} 


//Integration attempt with d3.js, albeit incomplete for data stretching

var projection = d3.geo.transverseMercator()
   .translate([terrainSize / 2, terrainSize / 2])
   .scale(10)
   .center([12.4309352,48.4640973]);    

//Iteration through the data for translation and geometry addition

for (var row in data_stretched) {
   var x = data_stretched[row][0]
   var y = data_stretched[row][2]
   var z = data_stretched[row][2]

   coord = translate(projection([y, x]));

   geometry.vertices.push(new THREE.Vector3(parseFloat(coord[0]), parseFloat(z),     parseFloat(coord[1]));
}


//Additional experiment involving translation functions

function translate(point) {
   return [point[0] - (terrainSize / 2), (terrainSize / 2) - point[1]];
}

//Rendering the plotted line

var line = new THREE.Line(geometry, material);
   scene.add(line);

//Configuration settings for camera and controls

var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, -terrainSize / 2, terrainSize / 2);

controls = new THREE.TrackballControls(camera);
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 0.2;
controls.panSpeed = 0.8;

controls.noZoom = false;
controls.noPan = false;

controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;

animate();

function animate() {
   requestAnimationFrame(animate);
   controls.update();
   renderer.render(scene, camera);
}

Desired visualization output resembling the stretched values applied for illustration purposes:

Answer №1

Problem resolved after adjusting the coordinate scale.

var projection = d3.geo.transverseMercator()
.translate([window.innerWidth, window.innerHeight])
.scale(30000000);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When ng-model is updated, form radio buttons trigger memories from the past, causing ng-check to malfunction

Angular 1.* Here is the code snippet: <div class="filter-column"> <div class="filter-title">Market</div> <div class="bottom-line"></div> <div class="overflow-container"> <input type="radio" val ...

How can you maintain the "link" text in a div while removing the final hyperlink?

I am currently designing a breadcrumb navigation for a website. The breadcrumbs are generated using a templating language before the page is displayed. However, after rendering the page, I need to make some adjustments. Instead of using multiple IF/ELSE s ...

Sharing information across various web pages

Struggling with PHP as a beginner. Currently using HTML5, CSS3, jQuery, and Bootstrap 4. I have 4 HTML pages on my site. The first page displays 4 squares labeled A, B, C, and D. Users select one square and click "Next" to proceed to page 2. Page 2 must ...

What could be the reason for the component failing to update even after modifying the object's properties?

I have come across some related threads on Stack Overflow, but they only briefly mention using the spread operator. But why should we use it? In the code below, I am trying to update the firstName property of the user object, which is a state, when clicki ...

Ways to prevent adding duplicate elements to a state array in React.js?

The state provided below is within my class component. I need to prevent adding duplicate objects to an array in my state as shown below: this.state = { frequency: { time: [ {time:"20:15",timezone:"IST"}, ...

Exploring the benefits of utilizing ng switch for more effective validation

Visit this link to see the code My goal is to display error messages one after another. I am considering using ng switch instead of ng:show for better efficiency, but my current approach is not working as expected. <div class="errorDiv" ng-switch on=" ...

Adding a div element to a React component with the help of React hooks

I'm currently diving into the world of React and experimenting with creating a todo app to enhance my understanding of React concepts. Here's the scenario I'm trying to implement: The user triggers an event by clicking a button A prompt app ...

Adjust the position of the content to the bottom for a form-group in Bootstrap v4

Currently, I am facing an issue where my label is overflowing and wrapping around the input field, causing it not to align at the bottom of the div. Is there a straightforward CSS solution for this problem? I have experimented with position relative/absol ...

Step-by-step guide on dynamically adding "Input Tags" to the DOM at runtime using Selenium's JavascriptExecutor

In order to dynamically add the following element to the DOM during run time, I need assistance... <input type="text" name="imagesToAdd" value="3566"> My initial attempt was to use Selenium JavascriptExecutor for this task. However, I encounter ...

Switching Angular Buttons

I am developing an Angular application with a Bootstrap theme that includes 2 radio buttons, each triggering a separate page. It is important that only one radio button can be selected at a time. I want the class values to be btn btn-primary active for the ...

How do I make the message "document.getElementById(...) is null" become true?

When running my code, only two of the document.getElementById calls (ctx1 and ctx2) successfully get values while the others (such as ctx3) do not. How can I ensure that all elements retrieve their values without receiving an error message? Below is a snip ...

Navigating focus to an overlay using Selenium

I am facing an issue with an overlay displaying terms on top of the main window. The scrollbars are not behaving as expected: https://i.sstatic.net/nzaUa.png The new window does not register as a separate 'window' or tab, so traditional methods ...

My Vue.js modal component isn't functioning as expected

I have a Vue JS modal component that is supposed to display all the names typed in the form, but it isn't working. As a newcomer to Vue JS, I'm having trouble understanding why it's not functioning properly. Additionally, I am unable to use ...

Ways to eliminate several DOM elements at once with a single JavaScript function

In my current project, I am faced with the task of removing various DOM elements from the page. This includes scenarios where I need to remove a single element as well as cases where I need to remove a collection of elements such as a NodeList or an HTMLCo ...

What is the list of NPM packages already included in the AWS Lambda execution environment?

I was surprised to discover that the aws-sdk NPM module comes preinstalled in AWS Lambda using nodejs8.10. I couldn't find any information online about this. Are there other node.js modules that are also pre-installed in AWS Lambda? ...

Hide the button with jQuery Ajax if the variable is deemed acceptable upon submission

I need to figure out how to hide the submit button if the email entered is the same as the one in the database from action.php. Can anyone help me with integrating this functionality into my existing code? <form onsubmit="return submitdata();"> ...

Is it possible to place a Three.js particle system in the background without it overlapping other objects

I am currently working with a particle system to create a beautiful starry background for my project. However, I'm facing an issue where the stars sometimes render too close to other objects in the scene instead of being purely in the background. Doe ...

Unable to save form data into mongoDB

Below is the code snippet from my app.js file: var express = require("express"), mongo = require("mongodb"), db = require("monk")("localhost:27017/nodemails"), bodyParser = require("body-parser"), logger = require("morgan"), path = require("path"); var a ...

What is the importance of maintaining immutability for objects in Redux?

What is the importance of immutability in Redux? While I understand that frameworks like Angular2 use onPush to leverage immutability for quicker rendering of views, I'm interested in learning about other reasons why Redux emphasizes immutability desp ...

Automatically showcase images from a directory upon webpage loading

Is there a way to modify my code so that the images from the first directory are displayed on the page when it loads, instead of waiting for a menu option to be clicked? The page looks empty until a menu option is selected, and I would like the images to s ...