Typescript Cannot find name 'functionName' - node.js

I have included the typings and referenced them.
I'm not sure if the typings are correct, since I don't know how to write them. But this is what I did:
// This is where I'm getting Cannot find name 'Polylabel'
geometry: polylabel(feat.geometry.coordinates)
I have included these typings:
declare module "polylabel" {
/**
* Polylabel returns the pole of inaccessibility coordinate in [x, y] format.
*
* #name polylabel
* #function
* #param {Array<number>} polygon - Given polygon coordinates in GeoJSON-like format
* #param {number} precision - Precision (1.0 by default)
* #param {boolean} debug - Debugging for Console
* #return {Array<number>}
* #example
* var p = polylabel(polygon, 1.0);
*/
function polylabel(polygon: number[][][], precision?: number, debug?: boolean): number[];
namespace polylabel {}
export = polylabel;}
And referenced it as follow:
/// <reference path="globals/#types/polylabel/index.d.ts" />

Instead of using /// <reference... add the .d.ts file to your tsconfig.json, on the "Files" section.
To use this module do this:
import * as polylabel from 'polylabel';
polylabel.polylabel(...)
or (If you are using namespaces and not imports)
polylabel.polylabel(...)

Related

Why i cant use acos function

I have a problem with this function. Excel return #name error.
=ACOS(COS(RADIANS(90-B3)) * COS(RADIANS(90-$G$3)) + SIN(RADIANS(90-B3)) * SIN(RADIANS(90-$G$3)) * COS(RADIANS(C3-$G$4))) * 6371

How to convert 'double' to ' VARIANT'

In my application via VC 2012, the ready function needs 'VARIANT' value as an input. I have a 'double' variable. Below is what I tired the conversion which didn't work. have searched online and failed to find the answer. Please advise. Thanks.
double db=19;
VARIANT v;
v.dblVal=19;
Below comment from one of window file will provide brief about supported data type of VARIANT
/*
* VARENUM usage key,
*
* * [V] - may appear in a VARIANT
* * [T] - may appear in a TYPEDESC
* * [P] - may appear in an OLE property set
* * [S] - may appear in a Safe Array
* * [C] - supported by class _variant_t
*
*
* VT_EMPTY [V] [P] nothing
* VT_NULL [V] [P] SQL style Null
* VT_I2 [V][T][P][S][C] 2 byte signed int
* VT_I4 [V][T][P][S][C] 4 byte signed int
* VT_R4 [V][T][P][S][C] 4 byte real
* VT_R8 [V][T][P][S][C] 8 byte real
* VT_CY [V][T][P][S][C] currency
* VT_DATE [V][T][P][S][C] date
* VT_BSTR [V][T][P][S][C] OLE Automation string
* VT_DISPATCH [V][T][P][S][C] IDispatch *
* VT_ERROR [V][T] [S][C] SCODE
* VT_BOOL [V][T][P][S][C] True=-1, False=0
* VT_VARIANT [V][T][P][S] VARIANT *
* VT_UNKNOWN [V][T] [S][C] IUnknown *
* VT_DECIMAL [V][T] [S][C] 16 byte fixed point
* VT_I1 [T] signed char
* VT_UI1 [V][T][P][S][C] unsigned char
* VT_UI2 [T][P] unsigned short
* VT_UI4 [T][P] unsigned short
* VT_I8 [T][P] signed 64-bit int
* VT_UI8 [T][P] unsigned 64-bit int
* VT_INT [T] signed machine int
* VT_UINT [T] unsigned machine int
* VT_VOID [T] C style void
* VT_HRESULT [T] Standard return type
* VT_PTR [T] pointer type
* VT_SAFEARRAY [T] (use VT_ARRAY in VARIANT)
* VT_CARRAY [T] C style array
* VT_USERDEFINED [T] user defined type
* VT_LPSTR [T][P] null terminated string
* VT_LPWSTR [T][P] wide null terminated string
* VT_FILETIME [P] FILETIME
* VT_BLOB [P] Length prefixed bytes
* VT_STREAM [P] Name of the stream follows
* VT_STORAGE [P] Name of the storage follows
* VT_STREAMED_OBJECT [P] Stream contains an object
* VT_STORED_OBJECT [P] Storage contains an object
* VT_BLOB_OBJECT [P] Blob contains an object
* VT_CF [P] Clipboard format
* VT_CLSID [P] A Class ID
* VT_VECTOR [P] simple counted array
* VT_ARRAY [V] SAFEARRAY*
* VT_BYREF [V] void* for local use
*/
You should use _variant_t instead of VARIANT.
Below code will convert your double value to variant,
_variant_t var(10.52);

time pattern in node-cronjob

I am using node-cron. Please help to explain to me the different between:
var pattern_1 = '58 * * * * *';
var pattern_2 = '*/58 * * * * *';
when running this function:
new CronJob(pattern, function() {
console.log('lalalalala')
}, null, true, 'America/Los_Angeles');
As described in cron man page:
Step values can be used in conjunction with ranges. Following a range
with ''/'' specifies skips of the number's value through the
range.
and:
Steps are also permitted after an asterisk, so if you want
to say ''every two hours'', just use ``*/2''.
So:
var pattern_1 = '58 * * * * *';
executes "at 58th seconds of every minute". The second pattern:
var pattern_2 = '*/58 * * * * *';
executes "every 58 seconds".
The first patterns will run your cronjob every 58th second: 00:00:58, 00:01:58, 00:02:58...and so on.
The slash character can be used to identify periodic values. For example */15 * * * * * means, that your job will run ever 15th second: 00:00:15, 00:00:30, 00:00:45 ...and so on.
In my opinion */58 doesn't look very useful. This will execute every 58th second of every minute, so just use the first one.
The second pattern:
var pattern_1 = '58 * * * * *';
It executes at "58th seconds of every minute".
The second pattern:
var pattern_2 = '*/58 * * * * *';
Same as pattern 1 so it also executes at "58th seconds of every minute".

Why isn't Doxygen documenting public class functions for my C# code?

I want to use Doxygen to document my c# code. So, I'm doing a trial run. So far it is not documenting the public functions in my test class. Here is my code:
/**
* #file doxyTest.cs
* #author Jon Plotner <plotnus#gmail.com>
* #version 1.0
*
* #section DESCRIPTION
* A test class for testing and running doxygen
*/
public class doxyTest{
/**
* Method1 adds the two numbers
* #param varA the first number to be added
* #param varB the second number to be added
* #returns An int which is the sum of varA and varB
*/
public int method1(int varA, int varB){
return a+b;
}
/**
* Method 2 compares the value of two numbers
* #param varA the first number
* #param varB the second number
* #return A bool, true if varA < varB
*/
public bool lessThan(int varA, int varB){
}
}
In the HTML output from Doxygen the "doxyTest Class Reference" is empty save for these lines:
The documentation for this class was generated from the following file:
*source/file1/doxyTest.cs
What am I doing wrong and how can I fix this?
The help is much appreciated as I've been trying to fix it myself for hours.

how to Calculate google map circle radius js to C#

I know how to use the javascript to calculate the radius by using the below code
var center = new google.maps.LatLng(3.2987599, 102.6872022);
var latLng = new google.maps.LatLng(3.0987599, 101.6872022);
var distanceInMetres = google.maps.geometry.spherical.computeDistanceBetween(center, latLng);
But how to convert the google.maps.geometry.spherical.computeDistanceBetween into C# function?
Distance between 2 points: (lat1,lon1) to (lat2,lon2)
distance = acos(
cos(lat1 * (PI()/180)) *
cos(lon1 * (PI()/180)) *
cos(lat2 * (PI()/180)) *
cos(lon2 * (PI()/180))
+
cos(lat1 * (PI()/180)) *
sin(lon1 * (PI()/180)) *
cos(lat2 * (PI()/180)) *
sin(lon2 * (PI()/180))
+
sin(lat1 * (PI()/180)) *
sin(lat2 * (PI()/180))
) * 3959
3959 is the Earth radius in Miles. Replace this value with
radius in KM, (or any other unit), to get results on the same unit.
You can verify your implementation by comparing to this worked example:
i have write the C# solution to calculate the distance to convert
var distanceInMetres = google.maps.geometry.spherical.computeDistanceBetween(center, latLng);
into C#. Below is the code i have using. 6371 is the radius of the Earth.
//Calculate distance earth between 2 coordinate point
double e = lat * (Math.PI / 180);
double f = lng * (Math.PI / 180);
double g = lat2 * (Math.PI / 180);
double h = lng2 * (Math.PI / 180);
double i =
(Math.Cos(e) * Math.Cos(g) * Math.Cos(f) * Math.Cos(h)
+ Math.Cos(e) * Math.Sin(f) * Math.Cos(g) * Math.Sin(h)
+ Math.Sin(e) * Math.Sin(g));
double j = Math.Acos(i);
double k = (6371 * j); //Distance in KM
The distance between 2 lat/long points can be calculated with the haversine formula, which is described here http://en.wikipedia.org/wiki/Haversine_formula
There also is another question here at stackoverflow about more or less the same issue: Calculate distance between two latitude-longitude points? (Haversine formula)

Resources