# Get coordinates of a satellite from http request

**URL:** <https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441>\
**Category:** General\
**Created:** [8 April 2020 08:31 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441 "2020-04-08T08:31:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 08:31 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/1 "2020-04-08T08:31:25Z")

</div>

Hi,  
I want to retrieve the coordinates of a satellite, so I can display it.  
However,

 ![satellite](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/a/aab38762e2fc31eaded9db83944bdd5dde572f3c.png) I retrieve the TLE data via an HTTP request.  
But I can't put it in the right format for the TLE function to convert the TLE data into Cartesian coordinates.  
I can't find any information about the function that can help me, so I rely on you.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 08:53 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/2 "2020-04-08T08:53:45Z")

</div>

did you read the [nodes notes](https://flows.nodered.org/node/node-red-contrib-satellites) and look at the examples?

---

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 08:55 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/3 "2020-04-08T08:55:48Z")

</div>

The nodes notes don't give any example, that's the problem.  
Even if i didn't see it.

---

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 08:56 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/4 "2020-04-08T08:56:52Z")

</div>

The examples are to use, the function "satellite" and not "TLE" that's my problem.  
Mine is not in the list so i have to give him the data

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 09:15 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/5 "2020-04-08T09:15:58Z")

</div>

So have you send the output of the `http-request` node to a debug node so you can see what the data looks like?

---

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 09:17 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/6 "2020-04-08T09:17:12Z")

</div>

Yes, it looks like a string including the 3 lines of the TLE data

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [8 April 2020 09:23 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/7 "2020-04-08T09:23:12Z")

</div>

Looking at the node's code, it doesn't appear to allow the TLE data to be supplied through input messages:

> <https://github.com/jdp1g09/node-red-satellites/blob/7ae20224d63a5de1dedcc890baf4e8def5d54558/satellites.js#L70-L79>

  
Looking at your flow above, it looks like you're trying to use a dynamic set of TLE data. Even when the parsing of your http response would go well, you're not able to use them with this node in its current form. I think you've to file an issue for this use case on the node's repository.

---

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 09:30 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/8 "2020-04-08T09:30:50Z")

</div>

Do you think it's possible to modify the source code to be able to use my http response ?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 09:36 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/9 "2020-04-08T09:36:39Z")

</div>

you need to send the data to a split node then after that send a msg setting  
msg.satid  
msg.tel1  
msg.tel2  
to the corect values and it will work.

I'm creating a issue on the node suggestion the author add such an example.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [8 April 2020 09:51 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/10 "2020-04-08T09:51:55Z")

</div>

If you can provide the example I'm sure we can get it fixed/added.  
I'm sure a PR would be appreciated.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 09:52 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/11 "2020-04-08T09:52:22Z")

</div>

You actually can send in the data, you need to set msg.satid, msg.tel1 and msg.tel2. The best way I found is to send the output of the `http-in` node to a `split` node. Send the output to the split to a switch and test msg.parts.index for a 0, 1, 2 and 3. Send each output to a change node.  
In the first change node, set msg.satid to msg.payload  
In the second, set msg.tel1 to msg.payload  
In the third, set msg.tel2 to msg.payload  
In the forth, set msg.payload to a timestamp  
and send the result to the TLE node

```auto
[{"id":"f7fe6450.9276b8","type":"inject","z":"ae5ddf35.d207","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":240,"wires":[["430e2c33.47bc54"]]},{"id":"430e2c33.47bc54","type":"http request","z":"ae5ddf35.d207","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://celestrak.com/satcat/tle.php?CATNR=44109","tls":"","persist":false,"proxy":"","authType":"","x":150,"y":300,"wires":[["ea5a9d7e.d55be8"]]},{"id":"ea5a9d7e.d55be8","type":"split","z":"ae5ddf35.d207","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":150,"y":360,"wires":[["3ad99d04.972882"]]},{"id":"3ba481d8.ac070e","type":"tle","z":"ae5ddf35.d207","satid":"M6P","tle1":"1 44109U 19018AF 20099.13260841 .00002228 00000-0 73746-4 0 9997","tle2":"2 44109 97.4708 168.0219 0060915 100.5916 315.6514 15.30648385 56824","coordsys":"latlongdeg","name":"","x":130,"y":560,"wires":[["3a2d4ef5.72f2a2"]]},{"id":"3a2d4ef5.72f2a2","type":"debug","z":"ae5ddf35.d207","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":130,"y":620,"wires":[]},{"id":"3ad99d04.972882","type":"switch","z":"ae5ddf35.d207","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":130,"y":420,"wires":[["a1480d7a.f1f94"],["5608bb5.0d34fc4"],["eb8bf9ca.b4a63"],["b202c21e.2e4568"]]},{"id":"a1480d7a.f1f94","type":"change","z":"ae5ddf35.d207","name":"","rules":[{"t":"set","p":"satid","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":360,"wires":[["2200b141.a8392e"]]},{"id":"5608bb5.0d34fc4","type":"change","z":"ae5ddf35.d207","name":"","rules":[{"t":"set","p":"tel1","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":400,"wires":[["2200b141.a8392e"]]},{"id":"eb8bf9ca.b4a63","type":"change","z":"ae5ddf35.d207","name":"","rules":[{"t":"set","p":"tel2","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":440,"wires":[["2200b141.a8392e"]]},{"id":"2200b141.a8392e","type":"join","z":"ae5ddf35.d207","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":590,"y":420,"wires":[["3ba481d8.ac070e"]]},{"id":"b202c21e.2e4568","type":"change","z":"ae5ddf35.d207","name":"set timestamp","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"date"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":480,"wires":[["2200b141.a8392e"]]}]

```

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [8 April 2020 09:52 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/12 "2020-04-08T09:52:42Z")

</div>

> [@zenofmud](#):
>
> to the corect values and it will work.
> 
> I'm creating a issue on the node suggestion the author add such an example.

Did you confirm this to work? Looking at the code it would be great if that was an option, but it wouldn't work in its current form. Because yes for `msg.satid`, but I can't see `msg.tle1` and `msg.tle2` to be working

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 09:53 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/13 "2020-04-08T09:53:49Z")

</div>

@afelix yup it does work, I just added an example to my prior post

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [8 April 2020 09:55 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/14 "2020-04-08T09:55:15Z")

</div>

Because based on the below, `msg.tle1` and `msg.tle2` are ignored regardless the value of the config parameters in the node. In fact, those properties aren't mentioned as such.

> <https://github.com/jdp1g09/node-red-satellites/blob/7ae20224d63a5de1dedcc890baf4e8def5d54558/satellites.js#L63-L95>

  
They are mentioned as properties from the node configuration, but not on the message object.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 09:58 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/15 "2020-04-08T09:58:04Z")

</div>

Give my flow a try and see what you get...

---

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 10:02 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/16 "2020-04-08T10:02:15Z")

</div>

![satellite2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/49cf3f83c1caae55679e5638e47b4394cc6283c9.png)  
Maybe I did something bad but it doesn't work for me.  
I used "string" to split.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 10:05 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/17 "2020-04-08T10:05:43Z")

</div>

Try the example I posted in my post above. you need to use the 'split' node

@dceejay I've just add a PR to the node with the example I gave above.

---

<div class="post-metadata">

**Author:** ![JustSeen](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JustSeen](https://discourse.nodered.org/u/JustSeen)\
**Post date:** [8 April 2020 10:08 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/18 "2020-04-08T10:08:41Z")

</div>

The timestamp overwrites all of my other msg

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 April 2020 10:09 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/19 "2020-04-08T10:09:47Z")

</div>

Did you use the flow I provided?

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [8 April 2020 10:10 UTC](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441/20 "2020-04-08T10:10:22Z")

</div>

There's a few issues with your flow, I'm updating them now. What's happening is that the split happens, then a switch on msg.parts.index and timestamp is set through "otherwise", but set to msg.payload. Join happens on "automatic", overwriting and putting the old payload back over the timestamp. Trying to get around that before I can check what actually happens.

[Next page](https://discourse.nodered.org/t/get-coordinates-of-a-satellite-from-http-request/24441.md?page=2)
