|
|
Here ya go.
Pay attention to the data format (see comments)
Needs scaling to fit (a) on the screen better and (b) on top of your image to
match locations
Better code would have methods built in to catch and reject erroneous data, etc.
But here are the basics.
=========================================================================
// Persistence of Vision Ray Tracer version 3.7
// Scene Description Language (SDL)
// File: Latitude / Longitude Mapping
// Version: 1.0
// Last updated: 29-Mar-2017
// Description: Read Latitude and Longitude from file and connect points on
map
//
// Author: Bill Walker "Bald Eagle", 2017
// email: see posts in news.povray.org
//
//------------------------------------------------------------------------
#version 3.7;
global_settings {
assumed_gamma 1.0
#default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
ambient_light rgb <1, 1, 1> // <======== flat, even illumination
}
#include "colors.inc"
camera {
location <0, 0, -1>
right x*image_width/image_height
look_at <0, 0, 0>
}
light_source{ <50, 50, -100> color rgb <1, 1, 1>}
// #declare EarthRadius = 6367; //radius in km
#declare EarthRadius = 6367*0.621371; //radius in mi
#macro S2C (Spherical)
// input - 2d vector: <Latitude, Longitude>
#local Lat = radians (Spherical.x);
#local Lon = radians (Spherical.y);
#local X = EarthRadius * cos(Lat) * cos(Lon);
#local Y = EarthRadius * cos(Lat) * sin(Lon);
#local Z = EarthRadius * sin(Lat);
#local Cartesian = <X, Y, Z>;
Cartesian;
#end // end macro S2C
#macro C2S (Cartesian)
#local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
2));
#local Lat = degrees (asin (Cartesian.z / R));
#local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
#local LatLon = <Lat, Lon>;
LatLon;
#end // end macro C2S
// data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
// etc.
#declare Type = "";
#declare Location = "";
#declare ID = "";
#declare Latitude = 0;
#declare Longitude = 0;
// count locations for sizing array
#declare Locations = 0;
#fopen DataFile "LatLongData.txt" read
#while (defined (DataFile))
#read (DataFile, Type, Location, ID, Latitude, Longitude)
#declare Locations = Locations + 1;
#end
#fclose DataFile
#declare _Type = array[Locations];
#declare _Location = array[Locations];
#declare _ID = array[Locations];
#declare _Latitude = array[Locations];
#declare _Longitude = array[Locations];
#declare _XYZ = array[Locations];
// input data into array
#declare Datapoint = 0;
#fopen DataFile "LatLongData.txt" read
#while (defined (DataFile))
#read (DataFile, Type, Location, ID, Latitude, Longitude)
#declare _Type [Datapoint] = Type;
#declare _Location [Datapoint] = Location;
#declare _ID [Datapoint] = ID;
#declare _Latitude [Datapoint] = Latitude;
#declare _Longitude [Datapoint] = Longitude;
#declare _XYZ [Datapoint] = S2C (<_Latitude[Datapoint],
_Longitude[Datapoint]>);
#declare Datapoint = Datapoint + 1;
#end
#fclose DataFile
#declare Marker = 0.25;
#declare Line = 0.05;
#declare Linecolor = pigment {Magenta};
#for (Point, 0, Locations-1)
#if (Type = "bus")
#declare Color = pigment {Red};
#elseif (Type = "subway")
#declare Color = pigment {Green};
#elseif (Type = "rail")
#declare Color = pigment {Blue};
#elseif (Type = "tram")
#declare Color = pigment {Yellow};
#else
#debug "Unidentified Location Type. \n"
#declare Color = pigment {White};
#end
#declare S = 1; //<0.1, 0.1, 1/4000>;
#declare T = <1350, 1130, -3500>;
sphere {0, Marker pigment {Color} translate _XYZ[Point]*S translate T}
#if (Point > 0)
cylinder {LastPoint*S, _XYZ[Point]*S, Line pigment {Linecolor} translate T}
#end // end if
#debug concat( "Vector = ", vstr(3, _XYZ[Point]*S, ", ", 3, 0), " \n")
#declare LastPoint = _XYZ[Point];
#end // end for Point
Post a reply to this message
|
|