def test_picture(self): t = Tikz("tizk_test1") p = TikzPicture(t, Point(20, 20), Point(190, 277)) p.draw_circle(Circle(Point(85, 128.5), 30)) p.draw_rectangle(Rectangle(Point(55, 98.5), Point(115, 158.5))) p.draw_circle(Circle(Point(85, 128.5), 95)) t.render()
def map_parallel(self, latitude): c = Circle(SphericalPoint(0, self.projection.origin_latitude), self.projection.origin_latitude - latitude) c = self.map_circle(c) crossings = self.circle_intersect_borders(c) if crossings: parallels = [] for i in range(len(crossings)): a1, c1, b1 = crossings[i - 1] a2, c2, b2 = crossings[i] if a1 > a2: a2 += 360.0 aavg = math.radians(0.5 * (a1 + a2)) pavg = c.center + Point(c.radius * math.cos(aavg), c.radius * math.sin(aavg)) if self.inside_maparea(pavg): arc = Arc(c.center, c.radius, a1, a2) p = self.gridline_factory.parallel(latitude, arc) parallels.append(p) else: p = self.gridline_factory.parallel(latitude, c) parallels = [p] return parallels
def test_multiple_pictures(self): t = Tikz("tikz_test2") p1 = TikzPicture(t, Point(20, 20), Point(190, 138.5)) p1.draw_circle(Circle(Point(85, 59.25), 30)) p1.draw_rectangle(Rectangle(Point(55, 29.25), Point(115, 89.25))) p2 = TikzPicture(t, Point(20, 158.5), Point(95, 277)) p2.draw_circle(Circle(Point(37.5, 59.25), 30)) p2.draw_rectangle(Rectangle(Point(7.5, 29.25), Point(67.5, 89.25))) with p2.clip(): p2.draw_circle(Circle(Point(37.5, 59.25), 40)) p3 = TikzPicture(t, Point(115, 158.5), Point(190, 277)) p3.draw_circle(Circle(Point(37.5, 59.25), 30)) p3.draw_rectangle(Rectangle(Point(7.5, 29.25), Point(67.5, 89.25))) t.render()
def parallel(self, latitude, min_longitude, max_longitude): p = self.project(SkyCoordDeg(self.center_longitude, latitude)) radius = p.distance(self.parallel_circle_center) return Circle(self.parallel_circle_center, radius)
def parallel(self, latitude, min_longitude, max_longitude): p = self.project(SkyCoordDeg(0, latitude)) return Circle(self.origin, self.origin.distance(p))
def map_parallel(self, latitude): p = SphericalPoint(0, latitude) radius = p.distance(self.projection.parallel_circle_center) center = self.projection.parallel_circle_center c = Circle(center, radius) c = self.map_circle(c) if self.bordered: crossings = self.circle_intersect_borders(c) if crossings: parallels = [] for i in range(len(crossings)): a1, c1, b1 = crossings[i - 1] a2, c2, b2 = crossings[i] if a1 > a2: a2 += 360.0 aavg = math.radians(0.5 * (a1 + a2)) pavg = c.center + Point(c.radius * math.cos(aavg), c.radius * math.sin(aavg)) if self.inside_maparea(pavg): arc = Arc(c.center, c.radius, a1, a2) p = self.gridline_factory.parallel(latitude, arc) p.border1 = b1 p.tickangle1 = a1 + 90 if self.gridline_factory.rotate_parallel_labels: if latitude > 0: p.labelangle1 = a1 + 90 else: p.labelangle1 = a1 - 90 else: p.labelangle1 = 0 p.border2 = b2 p.tickangle2 = a2 + 90 if self.gridline_factory.rotate_parallel_labels: if latitude > 0: p.labelangle2 = a2 + 90 else: p.labelangle2 = a2 - 90 else: p.labelangle2 = 0 parallels.append(p) else: if self.inside_maparea(c.center): p = self.gridline_factory.parallel(latitude, c) parallels = [p] else: parallels = [] else: if self.projection.reference_latitude > 0: start_angle = self.map_meridian( self.min_longitude).meridian.angle + 180 stop_angle = self.map_meridian( self.max_longitude).meridian.angle + 180 else: start_angle = self.map_meridian( self.max_longitude).meridian.angle stop_angle = self.map_meridian( self.min_longitude).meridian.angle a = Arc(c.center, c.radius, start_angle, stop_angle) p = self.gridline_factory.parallel(latitude, a) if self.projection.reference_latitude > 0: p.border1 = 'right' else: p.border1 = 'left' p.tickangle1 = start_angle + 90 if self.gridline_factory.rotate_parallel_labels: if self.projection.reference_latitude > 0: p.labelangle1 = start_angle + 90 else: p.labelangle1 = start_angle - 90 else: p.labelangle1 = 0 if self.projection.reference_latitude > 0: p.border2 = 'left' else: p.border2 = 'right' p.tickangle2 = stop_angle - 90 if self.gridline_factory.rotate_parallel_labels: if self.projection.reference_latitude > 0: p.labelangle2 = stop_angle + 90 else: p.labelangle2 = stop_angle - 90 else: p.labelangle2 = 0 parallels = [p] return parallels
def map_circle(self, circle): """This is a parallel circle....""" radius = self.map_distance(circle.radius) center = self.map_point(circle.center) return Circle(center, radius)
# Open log file with open(os.path.join(TEX_OUTPUT_FOLDER, self.name + ".log"), "r") as fp: output = fp.read() if xelatex_error: self.logger.debug(output) raise xelatex_error # Move output file if filepath: folder = os.path.dirname(filepath) if folder and not os.path.exists(folder): os.makedirs(folder) shutil.move(os.path.join(TEX_OUTPUT_FOLDER, f"{self.name}.pdf"), filepath) if open_pdf: subprocess.Popen(["open", filepath]).wait() return output if __name__ == "__main__": from skymap.tikz import TikzPicture from skymap.geometry import Circle, Rectangle, Point t = Tikz("tizk_test1") with TikzPicture(t, Point(20, 20), Point(190, 277)) as p: p.draw_circle(Circle(Point(85, 128.5), 30)) p.draw_rectangle(Rectangle(Point(55, 98.5), Point(115, 158.5))) t.render(verbose=True)
def xtest_label_director(self): ld = LabelManager() ld.add_object(Circle(Point(-1, 0), 0.5)) ld.add_object(Circle(Point(1, 0), 0.5)) ld.add_object(Circle(Point(1, 1), 0.5)) ld.add_object(Circle(Point(0, -1), 0.5))