diff --git a/apps.json b/apps.json index 81abdbfa1..8515fd153 100644 --- a/apps.json +++ b/apps.json @@ -2721,6 +2721,7 @@ {"name":"planetarium.app.js","url":"planetarium.app.js"}, {"name":"planetarium.data.csv","url":"planetarium.data.csv"}, {"name":"planetarium.const.csv","url":"planetarium.const.csv"}, + {"name":"planetarium.extra.csv","url":"planetarium.extra.csv"}, {"name":"planetarium.settings.js","url":"settings.js"}, {"name":"planetarium.img","url":"planetarium-icon.js","evaluate":true} ], diff --git a/apps/planetarium/README.md b/apps/planetarium/README.md index 030d25779..e922c55ac 100644 --- a/apps/planetarium/README.md +++ b/apps/planetarium/README.md @@ -24,4 +24,6 @@ Maybe you want to add some more constellations to the planetarium. As you can se - Find the two stars that you want to join in your constellation (a constellation line). For identifying a star you have to have a look at the name, usually something like `AL UMA` (alpha star of constellation ursa major). Lets say that you want to join stars 155 and 8 (this is constellation canis menor, that only has a line joining two stars). - Go to file `planetarium.const.csv` and add two lines for your new constellation. The first one will be the name of the constellation, the second one the pair of stars that you want to join, separated by coma (see the file for examples). - Do not forget to add a break line after the last constellation. -- Upload the new `planetarium.const.csv` to your bangle (or emualator) and test it out. +- Upload the new `planetarium.const.csv` to your bangle (or emulator) and test it out. + +What is a constellation star is not in the 500 star list in `planetarium.data.csv`? If you need another star to draw the constellation you can find that star in the full star list (`starinfo/planetarium.stars.csv`) and put it in `planetarium.extra.csv`. That stars will be loaded only when constellations are shown. In order to refer to these extra stars in the `planetarium.const.csv` you have to use the code `e_linenumber`, in order to differenciate them from the stars in the normal file. For instance, to refer to the first star in the file `planetarium.extra.csv`, you will refer it as `e_1`. Do not forget to add an extra line at the end as in the other files. diff --git a/apps/planetarium/planetarium.app.js b/apps/planetarium/planetarium.app.js index aae309941..4763efb82 100644 --- a/apps/planetarium/planetarium.app.js +++ b/apps/planetarium/planetarium.app.js @@ -39,7 +39,10 @@ function siderealTime(julianDay) * Draws a single star in the sky. * starPositions is a dictionary that gets modified and it is used later for ploting the constelations */ -function drawStar(zeta,theta,z,julianDay,latitude,longitude,starDE,starRA,starMag,starNumber,starPositions){ +function drawStar(zeta,theta,z,julianDay,latitude,longitude,starInfo,starNumber,starPositions){ + let starRA = parseFloat(starInfo[0]); + let starDE = parseFloat(starInfo[1]); + let starMag = parseFloat(starInfo[2]); var dec = Math.asin(Math.sin(theta) * Math.cos(starDE) * Math.cos(starRA + zeta) + Math.cos(theta) * Math.sin(starDE)); var ascen = Math.atan2(Math.cos(starDE) * Math.sin(starRA + zeta), Math.cos(theta) * Math.cos(starDE) * Math.cos(starRA + zeta) - Math.sin(theta) * Math.sin(starDE)) + z; var H = siderealTime(julianDay) - longitude - ascen; @@ -107,17 +110,28 @@ function plotSky(lat,lon,date){ starNumber++; //Process the star starInfo = line.split(','); - //console.log(starInfo[0]); - starRA = parseFloat(starInfo[0]); - starDE = parseFloat(starInfo[1]); - starMag = parseFloat(starInfo[2]); - drawStar(zeta,theta,z,julianDay,latitude,longitude,starDE,starRA,starMag,starNumber,starPositions); + drawStar(zeta,theta,z,julianDay,latitude,longitude,starInfo,starNumber,starPositions); linestart = lineend+1; lineend = f.indexOf("\n",linestart); } if (settings.constellations){ + //First plot the extra stars for the constellations + fe=storage.read("planetarium.extra.csv","r"); + linenum=linestart = 0; + lineend = fe.indexOf("\n"); + let starNumber = 0; + while (lineend>=0) { + line = fe.substring(linestart,lineend); + starNumber++; + starInfo = line.split(','); + drawStar(zeta,theta,z,julianDay,latitude,longitude,starInfo,"e_"+starNumber,starPositions); + linestart = lineend+1; + lineend = fe.indexOf("\n",linestart); + } + //End of ploting extra stars + linenum=linestart = 0; fc=storage.read("planetarium.const.csv","r"); lineend = fc.indexOf("\n"); @@ -131,14 +145,13 @@ function plotSky(lat,lon,date){ linestart = lineend+1; lineend = fc.indexOf("\n",linestart); g.setColor(0,255,0); - if (linenum>11) - break; + constelationShowing=false; for (j=0;j