Get latitude/longitude of an image’s corners (updated)

I created this same question a few days ago and I didn’t understand
why I received negative votes. Two people responded saying that “the
solution was already in other posts”, but no. Was not. My problem is
different and I proved it in the update I made.

I have an image that represents a region on the map. For example, this image is 10000px wide by 8000px high. I don’t know what the area of this region represented in the image is in terms of m².

What I can do is select a point in the image (x, y) and match that point on the map to get the latitude, longitude. I can do this with almost all points/pixels in the image except those on the edge (imagine that the image has a wide border that is just a white space, and I cannot relate these points within the map to obtain the latitude/longitude).

My goal is to add this image inside the map in a way that it fits perfectly on the map. For this I have to use Leaflet’s ImageOverlay feature. However, to use this feature, I need to specify the image’s bounds. In other words, I would need the latitude/longitude of two specific points in the image: bottom left and top right.

The first thing I tried was to obtain the equation of the line. As I have the relationship of two other points, I can draw the equation of the latitude/longitude line for this map and then obtain the latitude of every x/y. But as you can already imagine, since the map isn’t a “2d plane”, the straight line equation appears to be inefficient here.

In pixels, these points would be respectively (0px, 8000px) and (10000px, 0px). Unfortunately these are points that I cannot relate manually due to the mentioned border problem. Is there some kind of calculation I can do to get the latitude/longitude of these fields?

I’ve tried several alternatives, but all without success. I would greatly appreciate it if you could help me solve this problem.

UPDATES:

What I want is different from “Convert X,Y pixel to Longitude and Latitude” because in this example the user has precisely the latitudes/longitudes of the corners (max/min lat/long). Which is exactly what I need.

What I want is different from “Convert/distort image to match Mercator projection” because again the user knows the coordinates of all corners of the image. Which is exactly what I need.

I don’t think it’s necessary to share the code because I believe the problem is one of mathematics and not programming. What I can do is share the variables I have:

Image width: 15767px
Image height: 10629px

This image represents a region on the map, just like this image here.

I can relate some points more in the center of the image, such as:

var points = {
    a: {
        lat: -23.189714427995956,
        long: -45.95251764954021,
        x: 5896,
        y: 2908
    },
    b: {
        lat: -23.19225387170598,
        long: -45.95226547201594,
        x: 6123,
        y: 5432
    }
};

With these variables I need a function that returns the latitude/longitude of any point (x, y) within the image. Of course, my interest is not to obtain the latitude/longitude of ALL points. The points that really interest me are those necessary to obtain the image’s bounds and then be able to use the ImageOverlay feature correctly.

The points are bottom left (0, 10629) and top right (15767, 0).

import and export an html tag in 2 js files

i’ve two html file linked to two js files. i wanna save a html tag from html1 with js1 in an Variable and export it .
then import it in js2 file and use it in html2

i tried so many ways and didnt work,
simply like this

exporting:

html 1

        <div id="mainPageCont">
            <h2 id="defaultPage" style="text-align: center; margin: auto; width: 100%; height: 200; font-size: large; background-color: blue;">Default Main :))</h2>
        </div>

js 1

let mainPageContainer = document.getElementById("mainPageCont")
export default mainPageContainer;

importing:

html 2

        <div id="main-container"></div>

js 2

    import mainPageContainer from './Pages/Main/mainScripts.js' 
    document.querySelector("#main-container").innerHTML = mainPageContainer

How do I make the memory game in javascript?

I want to make a memory game with animal cards. How do I make the cards turn visible and invisible and how do i compare the cards with each other?

At this point it shows the cards name when it’s clicked but it needs to be a memory game dynamically made with javascript and html.

I tried to research for answers but i can’t find any.

This is what I tried, but I can’t come further then this:

"use strict";

const myCardSet = ["duck", "kitten", "piglet", "puppy", "calf", "veal", "lamb",
  "rooster", "horse", "mouse", "dog", "cat", "goose", "goat", "sheep", "pig", "cow",
  "chick", "hen"
];

document.addEventListener('onload', function() {
  populatieField()
})

class card {
  constructor(card1) {
    this.card1 = myCardSet[0]
  }
}

function populateField() {
  for (let i = 0; i < myCardSet.length; i++) {
    let newTile = document.createElement('div');
    let newCard = document.createElement('img');
    let imageURL = 'img' + card.card1 + '.jpg'
    newCard.setAttribute('src', imageURL)
    newCard.setAttribute('name', imageURL)
    newTile.appendChild(newCard)
    myField.appendChild(newTile)
    let img = {
      src: 'cover.png',
      class: '.covered'
    }
  }
}

const myField = document.getElementById('field')
myField.addEventListener('click', function onClickCard(e) {
  this.getAttribute(e.target.name)
  console.log(e.target.name)

})

function shuffle(arr) {
  var i = arr.length,
    j, temp;
  while (--i > 0) {
    j = Math.floor(Math.random() * (i + 1))
    temp = arr[j];
    arr[j] = arr[i]
    arr[i] = temp
  }
}

shuffle(myCardSet)
populateField()
<body>
  <div id="field"><img src="../begin/img/calf.jpg" alt="" name="calf">
    <img src="../begin/img/cat.jpg" alt="" name="cat">
    <img src="../begin/img/chick.jpg" alt="" name="chick">
    <img src="../begin/img/cow.jpg" alt="" name="cow">
    <img src="../begin/img/dog.jpg" alt="" name="dog">
    <img src="../begin/img/duck.jpg" alt="" name="duck">
    <img src="../begin/img/goat.jpg" alt="" name="goat">
    <img src="../begin/img/goose.jpg" alt="" name="goose">
    <img src="../begin/img/hen.jpg" alt="" name="hen">
    <img src="../begin/img/horse.jpg" alt="" name="horse">
    <img src="../begin/img/kitten.jpg" alt="" name="kitten">
    <img src="../begin/img/lamb.jpg" alt="" name="lamb">
    <img src="../begin/img/pig.jpg" alt="" name="pig">
    <img src="../begin/img/piglet.jpg" alt="" name="piglet">
    <img src="../begin/img/puppy.jpg" alt="" name="puppy">
    <img src="../begin/img/rooster.jpg" alt="" name="rooster">
    <img src="../begin/img/sheep.jpg" alt="" name="sheep">
    <img src="../begin/img/veal.jpg" alt="" name="veal">
    <img src="../begin/img/cat.jpg" alt="" name="cat">
    <img src="../begin/img/chick.jpg" alt="" name="chick">
    <img src="../begin/img/cow.jpg" alt="" name="cow">
    <img src="../begin/img/dog.jpg" alt="" name="dog">
    <img src="../begin/img/duck.jpg" alt="" name="duck">
    <img src="../begin/img/goat.jpg" alt="" name="goat">
    <img src="../begin/img/goose.jpg" alt="" name="goose">
    <img src="../begin/img/hen.jpg" alt="" name="hen">
    <img src="../begin/img/horse.jpg" alt="" name="horse">
    <img src="../begin/img/kitten.jpg" alt="" name="kitten">
    <img src="../begin/img/lamb.jpg" alt="" name="lamb">
    <img src="../begin/img/pig.jpg" alt="" name="pig">
    <img src="../begin/img/piglet.jpg" alt="" name="piglet">
    <img src="../begin/img/puppy.jpg" alt="" name="puppy">
    <img src="../begin/img/rooster.jpg" alt="" name="rooster">
    <img src="../begin/img/sheep.jpg" alt="" name="sheep">
    <img src="../begin/img/veal.jpg" alt="" name="veal">
  </div>

  <!-- script src="js/memory.js" type="module"></script -->
</body>

How Would I Make the (x,y,width,height) of a strokeRect a Var?

I’m trying to make a square in a canvas that moves(Tetris), and I want to know if there’s an alternative to making a independent fillRect. My line of thought is that I can make the fillRect() position and size based completely off of what the strokeRect is. I’m open to alternatives if there is a better way to do this.

I think it’s something like “var strokeX = ctx.strokeRect(xPos);” but I just don’t know enough about Java.

Get email after clicking button [closed]

I’m trying to capture the email after the customer clicks on the button next to the email, I tried some options but I lose the email information when I click.

To simulate, access the website https://opill.com/, go to the end where the email field is, click on the checkbox and then on the arrow inside the email form.

document.querySelectorAll("#email_74140190")

Thank you very much

Get the email in an attribute after click

How do I delete Data on click in reactjs

const ondeletehandle = async() => {
  const response = await fetch('/api/notebook/' + notebooks._id, {
    method: 'DELETE'

  })
  const json = await response.json()

  if (response.ok) {
    dispatch({
      type: 'DELETE_NOTEBOOK',
      payload: json
    })
    console.log(notebooks)
  }
  if (!response.ok) {
    console.log("error")
  }
}

i tried looking up for delete header but that didn’t work

closing window it’s not working for notice

Sign up page

I used devise for sign in and sign up with bootstrap in rails 7.1.3, however the shutting windows is not functioning for notice. Thank you for any assistance 😉

Fix the closing windows. I assume that javascript isn’t working correctly with Rails 7.1.3.

i got an error for PartialType is not working for updateDto

the partialType in not working for my updateDto it not making option my nested object variable in update dto. the main thing is that its only not working for boolean values mean not doing option boolean type in updateDto
here is createDto


class PoolDTO {
  @IsBoolean()
  present: boolean;

  @IsOptional()
  @IsString()
  fence: string;

  @IsOptional()
  @IsString({ each: true })
  location: string;
}
class UtilitiesDTO {
  @IsBoolean()
  sprinklerSystem: boolean;

  @IsBoolean()
  sumpPump: boolean;

  @IsBoolean()
  sumpPit: boolean;

  @ValidateNested()
  @Type(() => PoolDTO)
  pool: PoolDTO;

  @IsBoolean()
  spaHot: boolean;

  @IsBoolean()
  water: boolean;

  @IsBoolean()
  gas: boolean;

  @IsBoolean()
  electric: boolean;

  @IsOptional()
  @IsString()
  comment: string;
}
export class CreateDto{
   @IsString()
   @IsNotEmpty()  
   number: string;
 
    @ValidateNested()
    @Type(() => PoolDTO)
    pool: PoolDTO;

    @ValidateNested({ each: true })
    @Type(() => UtilitiesDTO)  
    utilities: UtilitiesDTO; 

and here is update dto

import { PartialType } from '@nestjs/mapped-types';
import { CreateDto } from './create.dto';


export class UpdateDto extends PartialType(CreateDto) {}

it gives me validation error

 "messages": [
        "utilities.sprinklerSystem must be a boolean value",
        "utilities.sumpPump must be a boolean value",
        "utilities.sumpPit must be a boolean value",
        "utilities.water must be a boolean value",
        "utilities.gas must be a boolean value",
        "utilities.electric must be a boolean value"
    ]

but i’m used PartialType
which is The PartialType() function returns a type (class) with all the properties of the input type set to optional.
still i’m getting error i’m not want to write updatedto want to used same createdto for updatedto

Using Aliases in a Javascript Function

I have a function responsible for constructing URLs using relative paths, such as ../../assets/images/content/recipe/. I want to replace the ../../assets/images part with a Vite alias, but it doesn’t work.

Here’s my function:

const getSrc = ext => {
    return new URL(
        `@img/content/recipe/${props.recipe.image}${ext}`,
        import.meta.url
    ).href;
};

And here’s Vite config for aliases:

'@img': fileURLToPath(
    new URL('./src/assets/images', import.meta.url)
),

I’m looking for a possible solution.

Matching not (0 or more ‘0’s) with JavaScript Regex

I am a bit stuck with writing a regex on JavaScript. I want to write a regex to match a string that is

  • starting with either of these letters: tysjod ;
  • and, if it contains only digits, NOT consisting of ONLY 0 or more ‘0’s

Test cases for matching:

  • “yes”
  • “1”
  • “1010”
  • ” 0 “

Test cases for not matching:

  • “no”
  • “0”
  • “00”
  • “”

I have written this so far but it isn’t quite right. I don’t know what is wrong:

return value.match(/(^[tysjod])|!(^0*$)/i);

Can I wrap ^ and $ in the brackets like this? Just wondering…

Alignment of line charts in a connection group when using Apache ECharts

When using the line charts from Apache ECharts I have connected 3 charts of data in a connection group that I need to line up properly based on their X axis, however the Echarts is increasing the scaling on one of the charts and as such the data is misaligned despite the pointer being at 20.6 on all graphs they do not line up
This is causing major issues with visual analysis of the data

Is there any features within the ECharts library to fix this.

I could process the data again however I wish to avoid mutating the data away from its original forms and reprocessing the data on the client side causes major performance issues especially when stacking multiple datasets onto the charts.

How to Connect to FIX Protocol in Node.js without fixparser.io?

I am working on integrating the FIX (Financial Information Exchange) protocol in a NodeJs application for financial trading. My goal is to establish a reliable and efficient connection to trading platforms using FIX. I have attempted to use several libraries aimed at facilitating this, including node-quickfix and exploring fixparser at fixparser.io, but encountered some challenges. fixparser.io seems like a suitable option; however, it is a paid service, and I am looking for open-source alternatives or solutions that could potentially offer similar functionality.

Here are the specific issues I’ve encountered:

  • With node-quickfix, I faced installation issues and also when i checked on there github handle it seems the library is not being maintained from last 2018 i have seen some open questions over there with no replies and also when i try to install this i am getting multiple errors.
  • As for fixparser.io, while it appears to meet our needs, the cost is a prohibitive factor, and we are exploring other avenues.

Given these challenges, I am seeking advice or recommendations on:

  1. Any open-source libraries or tools that are well-suited for connecting to FIX protocol in Node.js, especially those that are actively maintained and documented.
  2. Examples or guidance on setting up a FIX connection in Node.js without using fixparser.io, including handling session management, message parsing, and sending/receiving messages.
  3. Best practices for implementing FIX protocol connectivity in a Node.js environment, particularly from those who have successfully navigated this landscape.

I am open to alternative approaches or any insights into how others have successfully integrated FIX protocol support in their NodeJs applications. Thank you in advance for your help!

WebAssembly C++ using JS value – Import #0 module=”env”: module is not an object or function

I’m new to WebAssembly and I’m doing some experiments.

I managed to create very simple examples.

Now I would like to try using JS objects within my C++ code. Specifically,

I would like to try printing elements retrieved from windows such as location in C++ code.

This is my C++ code:

#include <string>
#include <emscripten.h>
#include <emscripten/val.h>

using namespace emscripten;

EMSCRIPTEN_KEEPALIVE
std::string decode_request(val window) {
    val location = window["location"];
    std::string search = location["search"].as<std::string>();
    size_t pos = search.find('?');
    if (pos != std::string::npos) {
        return search.substr(pos + 1);
    } else {
        return "";
    }
}

extern "C" {
    EMSCRIPTEN_KEEPALIVE
    const char* myFunction() {
        val window = val::global("window");
        std::string query = decode_request(window);
        return query.c_str();
    }
}

To compile, I’m using this command:

emcc -o module.js module_2.cpp -s EXPORTED_RUNTIME_METHODS="['ccall']"  -lembind

And this is the result:

module_2.cpp:24:16: warning: address of stack memory associated with local variable 'query' returned [-Wreturn-stack-address]
   24 |         return query.c_str();
      |                ^~~~~
1 warning generated.
cache:INFO: generating system asset: symbol_lists/83809947191162c2d512457e4d02c5266930142b.json... (this will be cached in "/Users/myuser/Documents/Emscripten/emsdk/upstream/emscripten/cache/symbol_lists/83809947191162c2d512457e4d02c5266930142b.json" for subsequent builds)
cache:INFO:  - ok

This is my HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WebAssembly Example</title>
</head>
<body>
    <h1>WebAssembly Example</h1>
    <p id="result">Result: </p>

    <button onclick="run()">Trigger</button>

    <script>
        function run() {
            WebAssembly.instantiateStreaming(
                fetch("wrapping.wasm"), {}
            ).then(result => {
                if (!result || !result.instance || !result.instance.exports) {
                    console.error("Failed to instantiate WebAssembly module.");
                    return;
                }

                var sum = result.instance.exports.myFunction();
                console.log("Result:", sum);

                document.getElementById("result").textContent = "Result: " + sum;
            }).catch(error => {
                console.error("Error loading WebAssembly module:", error);
            });
        }
    </script>
</body>
</html>

Unfortunately, I see this error in the console when I click on the button:

Error loading WebAssembly module: TypeError: WebAssembly.instantiate(): Import #0 module="env": module is not an object or function
(anonymous) @ (index):32
Promise.catch (async)
run @ (index):31
onclick @ (index):12

Any suggestions?

Why is ‘, ‘ translated to ‘%2C+’?

I am working on a project using Node.js v21.7.1, from a MariaDB database I query first name and surname then pass these back to the client.

In my SQL I use:

CONCAT(`t2`.`vcSurName`, ',', `t2`.`vcFirstName`) AS vcName

My client receives this and adds it to a ‘SELECT’ HTML tag, I can see the name is displayed correctly, for example ‘Platten, Simon’ is shown, this is now part of a form which when submitted, I can see that the server receives the name as:

'Platten%2C+Simon'

On the server I have used:

var strUserName = decodeURIComponent(objFields['biUID']);

I then split the name into an array:

var aryName = strUserName.split(', ');

This is where is goes wrong, decodeURIComponent only translates the %2C back to a comma, but the content of aryName now contains:

[Platten,+Simon]

What do I need to do because the + is the result of encoding the space but it doesn’t get decoded…