Code Monkey home page Code Monkey logo

log-reader's Introduction

logReader

Configurations

We use Node.js and create server of port: 3000

app.listen(3000, ()=> {
        console.log('Listen to port: 3000');
    });

After connecting to mongoDB, which we use to store our parsing data

Use las-js package from npm

// for parsing las files 
const Lasjs = require('las-js');

in the "routes" folder, you can find userRoutes.js where you can add and remove the routes you need. As example:

router.get('/', userController.getIndex);

router.get('/:filename/:header', userController.getLog);

router.get('/:id/multi/plot', userController.getMulti)

As we use "MVC" you can find your controllers in the "controllers" folder and code your desired function based on the router you choosed.

Parsing the .las file

First, we upload the file to the "uploads" folder and then, with the help of las-js package and async function you can read the file, get your desired data.

After that, and the most important, we changed the data from array format to ogject format to suit the model we have created on the "models" folder and save it to our mongoDB database.

const finalData = {};
for (var i=0; i < headers.length; i++){
var rowArray = [];
data.forEach(row => {
rowArray.push(row[i]);
});
finalData[headers[i]] = rowArray;
                  }

Creating our object and save it to our database

const myData = new Lasfile({
                    fileName: filename,
                    headers: headers,
                    headersDesc: headerAndDescr,
                    finalData: finalData
                        });
myData.save()

Display logs

we create a dynamic router containg the filename stored in our database and the desired header to view.

router.get('/:filename/:header', userController.getLog);

Depending on the header we can find the desired array of data, then render the ejs page with that information.

to display logs, we use D3.js which allows us to represent our data on svg graph created by our own.

Multi-plot

First, we render the ejs page with a data obtained from our data base. These data contain the object with keys equlas to the headers and each key has its own data of array.

exports.getMulti= (req, res, next) => {

    const id = req.params.id;
    Lasfile.findById(id)
    .then(data => {
        const headers = data.headers;
        const depthArr = data.finalData.DEPT;
        res.render('multi-plot', {
            pageTitle: "Multi Plot Area",
            headers: headers,
            depthArr: depthArr,
            finalData: data.finalData
        });
    })
    .catch(err => {
        console.log(err);
    })

}

The most important part is to detect the selected arrays that you want to plot

$(document).ready(function() {
      $(":checked").each(function(){
        selectedArray.push($(this).val());
      });

After that we send these data to D3.js to plot

log-reader's People

Contributors

almersawi avatar islammers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.