Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:02:37+00:00 2026-05-31T01:02:37+00:00

I am trying to draw a bus route as a simple sequence of lines.

  • 0

I am trying to draw a bus route as a simple sequence of lines. Nothing fancy. But instead of lines, I’m getting wedges. Initially I was fine with this, because the wedges sortof look like arrows and always face towards the second point. But now I want to improve the look, and the wedges are becoming a big problem.

My suspicion is some sort of floating-point issue due to the graphics transform (lat/lons are fed in and the transform turns them into x/y on the bitmap [assuming lat/lon is euclidean is accurate enough for my purposes], so the scaling is several orders of magnitude).

Screenshot:

'Wedge' line overlayed over a road

It actually kind of looks like the line was split into two triangles but only one of them was drawn.

Relevant Code (note: drawing is done asynchronously, which is why I’m creating a bitmap):

'-- Creating the transform --'
Dim bitmap = New Bitmap(Math.Max(1, PictureBox1.Width), Math.Max(1, PictureBox1.Height))

Dim g = Graphics.FromImage(bitmap)
g.TranslateTransform(0, bitmap.Height)
g.ScaleTransform(1, -1)
g.ScaleTransform(CSng(bitmap.Width) / (maxLon - minLon), CSng(bitmap.Height) / (maxLat - minLat))
g.TranslateTransform(-minLon, -minLat)

'-- Drawing the lines (in a method called asynchronously) --'
using pen = New Pen(Brushes.Black, 0.0001)
Dim shapes = busData.TripsInGroup(tripGroup.Value).
             Select(Function(e) e.Shape).
             Distinct()
For Each shape In shapes
    For i = 0 To shape.Points.Count - 2
        Dim e1 = shape.Points(i)
        Dim e2 = shape.Points(i + 1)
        Dim p1 = New PointF(CSng(e1.Longitude), CSng(e1.Latitude))
        Dim p2 = New PointF(CSng(e2.Longitude), CSng(e2.Latitude))
        g.DrawLine(pen, p1, p2)
    Next
Next

Example values:

cenLat = 44.657176
cenLon = -63.549471
spnLat = 0.071921
spnLon = 0.179729
minLat = cenLat - spnLat / 2
maxLat = cenLat + spnLat / 2
minLon = cenLon - spnLon / 2
maxLon = cenLon + spnLon / 2
shpts = {(Lat: 44.6518683235, Lon: -63.5930836628), 
         (Lat: 44.6512537117, Lon: -63.5927528307), 
         (Lat: 44.6508013753, Lon: -63.5924572976), 
         (Lat: 44.6503312812, Lon: -63.5921923044), 
         (Lat: 44.6503312812, Lon: -63.5921923044), 
         (Lat: 44.6502137576, Lon: -63.5921260568), 
         (Lat: 44.6495810455, Lon: -63.5917829189), 
         (Lat: 44.648893839, Lon: -63.5913776026), 
         (Lat: 44.6485468163, Lon: -63.5911976944), 
         (Lat: 44.6485468163, Lon: -63.5911976944), 
         (Lat: 44.6475084762, Lon: -63.5906617219), 
         (Lat: 44.6475084762, Lon: -63.5906617219)}

Notes and discoveries:

  • Using DrawLines instead of DrawLine solves the issue (but why?)
  • Increasing the pen thickness makes the issue go away (but the lines are too thick)
  • Zooming out (increasing lat/lon view window) makes the issue go away, eventually (but I want to zoom in!)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:02:38+00:00Added an answer on May 31, 2026 at 1:02 am

    I had this same issue, and stumbled across this thread. Unlike the OP I found that DrawLines did not solve the issue and suffered from the same problem as DrawLine.

    Gabe is correct in that the issue is with regard to the precision of the internal drawing algorithms.

    I solved the problem by scaling up the lat/long values by a factor of 10 (although if you are doing more zooming in you may need to scale up by more) before passing them to any drawing algorithm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to draw a simple rectangle in my iOS cocos2d game, but
I am trying to draw a picture to the window but it is only
I'm trying to draw a simple box in my iPhone game. Here is the
I am trying to draw some circles on a view in MonoMac, but I
I am trying to draw a rectangle where I am initially providing it values
I am trying to draw a line using the Graphics 2D but then the
I'm trying to draw a bitmap in flex,the original bitmap is but, actually it
I am trying to draw a Hand of Cards (in the Hand class) but
I'm trying to draw a simple line graph which would use values from the
I'm trying to draw a gradient in Flash using beginGradientFill and drawRect , but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.