Convert Java Script functions to extension

Can the functions be converted into an extension from the following link?
https://www.orchids.de/kthilf/javascripts.html

Extensions are written in java and JavaScript cannot be converted to Java.
Things you can do

  • make an extension which do the same calculation/logic
  • Use webview for executing javascript
  • create a backend with javascript and do apo call using web component
2 Likes

What would programming as an extension cost?

I can try to make JavaScript evaluation

@Jerin_Jacob possibly, this library is bit closer to what he wants

1 Like

It works using webview which is already present as component.

2 Likes
1 Like

Yes web viewer will does in simple if he use correct js code

2 Likes

You could just simply do this using a webview, creating another extension looks unnecessary. There is a block to eval JS in Kodular.

2 Likes

I agree with @Still-learning @Xoma, Developing an extension is unnecessary. You can simply use webview component and execute javascripts.

2 Likes

And the topic should be in Discuss or Marketplace request category.

2 Likes

My problem is, I have no idea about Javascript. I wrote a procedure for “gk2geo” with an Excel calculation. But I also need the other functions.

Maybe explain us more?

1 Like

may i know what are you trying to achieve

Don’t know if this helps

I have a CSV file with Gauss-Krueger survey data. In order to be able to show them on the map, I have to convert them to GPS. That already works with the procedure. But then the coordinates are not yet accurate. Function “pot2wgs” and
“wgs2pot” ensure more accuracy.

Fail to implement this function.
`function pot2wgs(lp, bp)
{
/* Copyright (c) 2006, HELMUT H. HEIMEIER
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.*/

/* Die Funktion verschiebt das Kartenbezugssystem (map datum) vom in
Deutschland gebräuchlichen Potsdam-Datum zum WGS84 (World Geodetic
System 84) Datum. Geographische Länge lp und Breite bp gemessen in
grad auf dem Bessel-Ellipsoid müssen gegeben sein.
Ausgegeben werden geographische Länge lw und
Breite bw (in grad) auf dem WGS84-Ellipsoid.
Bei der Transformation werden die Ellipsoidachsen parallel
verschoben um dx = 587 m, dy = 16 m und dz = 393 m.*/

// Geographische Länge lp und Breite bp im Potsdam Datum
if (lp == “” || bp == “”)
{
lw = “”;
bw = “”;
return;
}

lp = parseFloat(lp);
bp = parseFloat(bp);

// Quellsystem Potsdam Datum
// Große Halbachse a und Abplattung fq
a = 6378137.000 - 739.845;
fq = 3.35281066e-3 - 1.003748e-05;

// Zielsystem WGS84 Datum
// Abplattung f
f = 3.35281066e-3;

// Parameter für datum shift
dx = 587;
dy = 16;
dz = 393;

// Quadrat der ersten numerischen Exzentrizität in Quell- und Zielsystem
e2q = (2fq-fqfq);
e2 = (2f-ff);

// Breite und Länge in Radianten
pi = Math.PI;
b1 = bp * (pi/180);
l1 = lp * (pi/180);

// Querkrümmungshalbmesser nd
nd = a/Math.sqrt(1 - e2q*Math.sin(b1)*Math.sin(b1));

// Kartesische Koordinaten des Quellsystems Potsdam
xp = nd*Math.cos(b1)Math.cos(l1);
yp = nd
Math.cos(b1)*Math.sin(l1);
zp = (1 - e2q)ndMath.sin(b1);

// Kartesische Koordinaten des Zielsystems (datum shift) WGS84
x = xp + dx;
y = yp + dy;
z = zp + dz;

// Berechnung von Breite und Länge im Zielsystem
rb = Math.sqrt(xx + yy);
b2 = (180/pi) * Math.atan((z/rb)/(1-e2));

if (x > 0)
l2 = (180/pi) * Math.atan(y/x);
if (x < 0 && y > 0)
l2 = (180/pi) * Math.atan(y/x) + 180;
if (x < 0 && y < 0)
l2 = (180/pi) * Math.atan(y/x) - 180;

lw = l2;
bw = b2;
return;
}`

If you already have a function writen in JavaScript, no need to write again with blocks, just use the Webview.evalulateJs to run this function.

Can you describe how I can get the return values?

Use ‘after java script evaluated’ block which has return values