javascript epsg ITRF96 (7932) coordinates to lat long

javascript epsg ITRF96 (7932) coordinates to lat long (exp; y:599401,930828285 x:4521295,37679838)

Itrf96 data has coordinates that are required to convert these coordinates to Google Earth. How do I do this? I would appreciate it if you could answer using sample itrf96 coordinates.
Thanks

python with a javascript subprocess

I am trying to start a javascript subprocess inside a python script.

I’d like to do some photo analysis, by using the Human repo, which doesn’t have any Python porting (natively js), so I must execute his detect function in javascript

The general idea is to start a Python code to take a picture from webcam (this is a project’s constraint) and then process the photo inside the js script.

(the best thing would be not to save the photo but to directly pass it to the js script, which I tried by frame_json = json.dumps(frame.tolist()) and then process.communicate(input=frame_json) but it didn’t work anyway)

This is my python code:

import cv2
import json
import subprocess
import asyncio

def capture():
    video_capture = cv2.VideoCapture(0)

    while True:
        # Grab a single frame of video
        ret, frame = video_capture.read()

        if not ret:
            break         
        #cv2.imwrite('photo1.png', frame)
        try:
            
            js_command = ['node', 'detect.js']
            process = subprocess.Popen(js_command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
            output, output2 = process.communicate(input='photo1.png')
            
            print(f'h_res: {output}')
            return output.strip()
            
        except Exception as e:
            print(e)
            return None

capture()

whereas this is the javascript:

const tf = require('@tensorflow/tfjs-node'); 
const Human = require('@vladmandic/human').default; // points to @vladmandic/human/dist/human.node.js
const fs = require('fs');

process.stdin.setEncoding('utf-8');

const config = {
    modelBasePath: 'file://HumanNPM/node_modules/@vladmandic/human/models',
    body: { enabled: true, modelPath: 'file://node_modules/@vladmandic/human/models/models.json' },
};

function newFunction(inputFile) {
    
    const human = new Human(config);
    const buffer = fs.readFileSync(inputFile); // read file content into a binary buffer
    const tensor = human.tf.node.decodeImage(buffer); // decode jpg/png data to raw pixels

    
    res = human.detect(tensor, config).then((result) => {
        
        process.stdout.write(result);
        
        console.log(result)
        return result;
    });
    

    return res
}


process.stdin.on('data', function (data) {
    newFunction(data)
});


process.stdin.on('end', function () {
    process.exit();
});

The problem is that it seems like the Human library doesn’t execute, since I don’t see anything in my python output.
Obviously if I comment the Human section out and console.log('something') from the js, I am able to see it in my Python console.

I can’t figure out if is there something out that I’m missing.

Is there any concurrency problem? Or is there any chance that I’m using the library wrong in some way? (the library still works fine if used by itself without being used as subprocess, with node detect.js).

May someone give me an help?

Not able to show header after 2 scroll-up counts. Currently shows on 1 scroll up count

Currently, the header hides when scrolling down and shows when scrolling up once. I would like the header to show only when scrolling up twice or more times.

const body = document.body
let lastScroll = 0;
let scrollUp_Count = 0;

window.addEventListener('scroll', () => {
  const currentScroll = window.pageYOffset


  //top of the page
  if (currentScroll <= 0) {
    body.classList.remove("scroll-up")
    scrollUp_Count = 0
  }

  // Scrolling down
  if (currentScroll > lastScroll && !body.classList.contains("scroll-down")) {
    body.classList.remove("scroll-up")
    body.classList.add("scroll-down")
    scrollUp_Count = 0

  }
  // Scrolling up
  if (currentScroll < lastScroll && body.classList.contains("scroll-down")) {
    body.classList.remove("scroll-down")
    scrollUp_Count++
    // body.classList.add("scroll-up")

    if (scrollUp_Count >= 2) {
      body.classList.add("scroll-up")
    }
  }

  lastScroll = currentScroll
})
/* header is the navbar or the header itself */
.scroll-down header {
  transform: translate3d(0, -100%, 0)
}

.scroll-up header {
  filter: drop-shadow(0 -10px 20px rgb(170, 170, 170))
}

Why ESM slower than CJS?

I have two code

One is:

1. a.mjs(ESM)

function Worker(health) {
  this._health = health ?? 10;
}

function JuniorEngineer(health, intelligence) {
  this._super(health);
  this._intelligence = intelligence ?? 1;
  this._isBornGenius = intelligence > 10;
}

Worker.prototype.work = function () {
  this._health--;
};

Worker.prototype.getHealth = function () {
  return this._health;
};

JuniorEngineer.prototype = Object.create(Worker.prototype, {});

JuniorEngineer.prototype._super = function (health) {
  return Worker.call(this, health);
};

JuniorEngineer.prototype.getIntelligence = function () {
  return this._intelligence;
};

JuniorEngineer.prototype.work = function () {
  Worker.prototype.work.call(this);
  this._intelligence++;
};

JuniorEngineer.prototype.isBornGenius = function () {
  return this._isBornGenius;
};

function main() {
  var startTime = performance.now();
  console.time();
  const amount = 10000000;
  for (var i = 0; i < amount; i++) {
    const junior = new JuniorEngineer(10, Math.floor(Math.random() * 20));
    // %DebugPrint(junior);
    junior._isBornGenius;
  }
  var endTime = performance.now();
  console.timeEnd();

  // console.log(endTime - startTime);
}

main();

export { Worker, JuniorEngineer };

And another is:
2. a.js(CJS)

function Worker(health) {
  this._health = health ?? 10;
}

function JuniorEngineer(health, intelligence) {
  this._super(health);
  this._intelligence = intelligence ?? 1;
  this._isBornGenius = intelligence > 10;
}

Worker.prototype.work = function () {
  this._health--;
};

Worker.prototype.getHealth = function () {
  return this._health;
};

JuniorEngineer.prototype = Object.create(Worker.prototype, {});

JuniorEngineer.prototype._super = function (health) {
  return Worker.call(this, health);
};

JuniorEngineer.prototype.getIntelligence = function () {
  return this._intelligence;
};

JuniorEngineer.prototype.work = function () {
  Worker.prototype.work.call(this);
  this._intelligence++;
};

JuniorEngineer.prototype.isBornGenius = function () {
  return this._isBornGenius;
};

function main() {
  var startTime = performance.now();
  console.time();
  const amount = 10000000;
  for (var i = 0; i < amount; i++) {
    new JuniorEngineer(10, Math.floor(Math.random() * 20)).isBornGenius();
  }
  var endTime = performance.now();
  console.timeEnd();

  // console.log(endTime - startTime);
}

main();

module.exports = { Worker, JuniorEngineer };

when i run two file with command node a.js and node a.mjs and result is:
ESM
145.3415

CJS
59.676541

Why this is happen? Actually i think is not a loading mechanism’s problem. When i measure average time of create instance, CJS more faster than ESM when create instance. How this can be happen?

I asked to gpt but i can’t get reasonable answer….

How to make FragmentHighlighter to highlight an element with pure highlighter’s color in openbim-components (IFCjs) + THREE.js

I using openbim-components (IFCjs) library alongside with THREE.js and face a problem that a tool for highlighting in openbim-components library (FragmentHighlighter) just adds a new mesh (with a material for highlighting – in my case it is a gray color) to the scene. Meaning that the old mesh is still there.
Apparently, this collision creates an effect of overlapping: both meshes are in the same place, but their materials are different. So the materials are mixing.
If elements are white highlighting work as it must
But if elements’ meshes are not white the highlighting overlaps and mixes
I need to achieve a highlight color (pure gray as at the first image) to be when elements are not gray (as at the second image).
Thanks in advance!

I attempted to set:

material.polygonOffset = true
material.polygonOffsetFactor = 1
material.polygonOffsetUnits = 1

to the first mesh’s material, but it didn’t work
Any attempts to adjust depthTest (true for the highlighter’s matertial and false for the element’s one) failed, too

why a normal input tag is not firing change event on enter button click but an input tag sitting inside shadow DOM is firing change event?

JSFiddle Link : https://jsfiddle.net/nx194eqc/

class CustomInput extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: 'open' });
    this.shadowRoot.innerHTML = `<input class="test" type="text" />`;
  }

  connectedCallback() {
    const input = this.shadowRoot.querySelector(".test");
    input.addEventListener("change", this.changeHandler);
  }
  
  changeHandler(e) {
      e.preventDefault();
      console.log(e.target.value)
  }
}

customElements.define('custom-input', CustomInput);
<custom-input></custom-input>

input tag present in shadow DOM is firing change event on enter key press and wants to know how to get rid of that ? or any alternative approach available ?

lite youtube: youtube video embed end listener, For example I want to play another video after it, but “end” parameter is not for that use

I want another embed video to play automatically after the end of another using lite-yt-embed.js. I am trying to study how to get exact end parameter of a youtube video embed, but I think “end” parameter is only used in modifying what time you want the video to end.
Lite youtube js link:
https://github.com/paulirish/lite-youtube-embed

This is what was stated in the developers.google:
end: This parameter specifies the time, measured in seconds from the start of the video, when the player should stop playing the video. The parameter value is a positive integer.

I have tried using “end” parameter, it really just modifies the time of the end of the video.
I am trying to learn to make video end listener, but the parameter was not stated in https://developers.google.com/youtube/player_parameters

There is an error in React that I don’t understand. Please help. Thank you

enter image description here
export ‘withRouter’ (imported as ‘withRouter’) was not found in ‘react-router-dom’ (possible exports: AbortedDeferredError, Await, BrowserRouter, Form, HashRouter, Link, MemoryRouter, NavLink, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_FetchersContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_ViewTransitionContext, UNSAFE_useRouteId, UNSAFE_useScrollRestoration, createBrowserRouter, createHashRouter, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, createSearchParams, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, unstable_HistoryRouter, unstable_usePrompt, unstable_useViewTransitionState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit)

enter image description here
export ‘withRouter’ (imported as ‘withRouter’) was not found in ‘react-router-dom’ (possible exports: AbortedDeferredError, Await, BrowserRouter, Form, HashRouter, Link, MemoryRouter, NavLink, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, ScrollRestoration, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_FetchersContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_ViewTransitionContext, UNSAFE_useRouteId, UNSAFE_useScrollRestoration, createBrowserRouter, createHashRouter, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, createSearchParams, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, unstable_HistoryRouter, unstable_usePrompt, unstable_useViewTransitionState, useActionData, useAsyncError, useAsyncValue, useBeforeUnload, useBlocker, useFetcher, useFetchers, useFormAction, useHref, useInRouterContext, useLinkClickHandler, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, useSearchParams, useSubmit)

Can one Observable have multiple subscribers?

I have one Observable and I thought that one Observable can have only one subscriber. But the code below subscribes twice and works fine for two subscribers – how come? (What I mean is both received0 and received1 are printed)

const observable = new Observable((subscriber) => {
      sub : Subscriber;
      
      setTimeout(() => {
        subscriber.next(4);
        subscriber.complete();
      }, 2000);
    });
    observable.subscribe({
      next: (value) => {
        console.log("received0: "+value);
      }
    });
    observable.subscribe({
      next: (value) => {
        console.log("received1: "+value);
      }
    });

How to download DICOM images from Microsoft DICOM in Angular

I am using the DICOMweb-client library to retrieve DICOM images from a remote DICOMweb server. The response I receive from the server is in the form of an array buffer containing DICOM image data.

Here is a simplified version of my code:

import * as DICOMwebClient from 'dicomweb-client'

const options = {
    url: 'https://d33do7qe4w26qo.cloudfront.net/dicomweb',
    studyInstanceUID: '2.16.840.1.114362.1.11972228.22789312658.616067305.306.2',
    seriesInstanceUID: '2.16.840.1.114362.1.11972228.22789312658.616067305.306.3',
    sopInstanceUID: '2.16.840.1.114362.1.11972228.22789312658.616067305.842.154',
    mediaTypes: ['image/dicom+jp2; transfer-syntax=1.2.840.10008.1.2.4.90'],
    singlepart: true
};

// Create a DICOMweb client instance
const client: any = new DICOMwebClient.api.DICOMwebClient(options);

// Retrieve study data
let retrieveStudy = client.retrieveStudy({ studyInstanceUID: '2.16.840.1.114362.1.11972228.22789312658.616067305.306.2' })
    .then((studyData: any) => {
        console.log("studyData", studyData)
    })

Now, I need to convert this array buffer into DICOM format so that I can download the DICOM images. I have attempted to use the multipart decoder provided by the dcm4che library, but it’s not working as expected.

Can someone guide how to correctly convert the array buffer containing DICOM image data into DICOM format using the multipart decoder? Any help or suggestions would be greatly appreciated. Thank you!

The output will be from this URL “https://d33do7qe4w26qo.cloudfront.net/dicomweb” We can download the dicom images in the zip format in the local machine.

Class or function, style or substance for asynchronous instantiation?

I have a class which I have been returning an anonymous, immediately invoked
asynchronous from in the constructor. I’m using the code as such

var encoder = await new Encoder();
var start = await encoder.start();

I do that to import a dependency on the 1st request, thereafter the library is
imported from local cache. Either way the process is asynchronous to load the
Ecmascript Module. The initialization process also includes using
WebAssembly.instantiate() which is also asynchronous.

I read Async/Await Class Constructor
and Is it bad practice to have a constructor function return a Promise?
re returning an asynchronous function
from the class constructor.

I don’t think it makes a difference as long as the caller is expecting
a Promise from the constructor.

From my perspective, if the class requires an asynchronous process to initialize, rewiring that initialization
as a static method does not get rid of the asynchronous initialization. It just
moves that process to a different part of the code that still has to run before
other methods for the class to work.

That is, in code I see no difference between

Engine.load({path: '/path/to/posts'}).then(function(posts) {
    new Engine(posts).displayPosts();
});

or

class myClass {
  constructor(async_param) {
    if (typeof async_param === 'undefined') {
      throw new Error('Cannot be called directly');
    }
  }

  static build() {
    return doSomeAsyncStuff()
      .then(function(async_result) {
        return new myClass(async_result);
      });
  }
}

from the top answers in the linked questions and

const encoder = await new Encoder();

or

const encoder = await new Encoder().instantiate();

or we could even use more than one line

const encoder = new Encoder();

try {
  await encoder.instantiate();
} catch (e) {
  console.warn(e);
  console.trace();
}

Either way the asynchronous process is expected beforehand by the caller. So why
not just return the Promise from the constructor for transparency – the object expected
is the Promise.

In this case would an asynchronous function serve the same purpose
as using a class, and come with transparency without ambiguity.

async function Encoder() {
  // Import from network once, local cache thereafter
  const _Encoder = await import(netOnceThenCache);
  const wasm = await WebAssembly.instantiate(buffer);
  return _Encoder;
}


const encoder = await encoder();
const start = await encoder.start();

Do you use the static method approach, or an asynchronous function, or just return a Promise from your constructor, consensus be damned?

Provided full disclosure in documentation and comments does it really matter technically?

When generating a debug APK, I encountered an error. How can I resolve this issue?

When generating a debug APK, I encountered an error. How can I resolve this issue?

“react-native”: “0.72.5”,
“@react-native-camera-roll/camera-roll”: “^7.5.0”,

Task :@react-native-camera-roll_camera-roll:extractDebugAnnotations FAILED

FAILURE: Build failed with an exception.

What went wrong:
A problem was found with the configuration of task ':@react-native-camera-roll_camera-roll:extractDebugAnnotations' (type 'ExtractAnnotations').
Gradle detected a problem with the following location: 'C:Users91950Desktopmobile appalbia_appnode_modules@react-native-camera-rollcamera-rollandroidbuildgeneratedaidl_source_output_dirdebugout'.

Reason: Task ':@react-native-camera-roll_camera-roll:extractDebugAnnotations' uses this output of task ':react-native-camera-roll_camera-roll:compileDebugAidl' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

Using JSON as CMS for Web Application

Is it a good idea to use JSON as CMS for managing content that can change frequently by admins. And can this JSON(s) be hosted on S3 and still deliver good performance.
What are some good alternative solutions for this usecase.