GoogleMap: Polyline doesn't draw all Options - c#

On a GoogleMap I am drawing a polyline to show a route. The lat/long-data is requested via Google Directions API and I receive correct data, usually for two different cities, from which I extract the lat/long-values and add it to an Polyoptions-object, which is added to the Polyline of the Map. Whatever the route is long, how much positions/latLng are available, the route never has more than around 8 straight lines. I have read a lot of stuff, and I can be sure, that the route is created correctly, I can even delete one to create another one. I have also tried "geodesic()" with true an false. No change.
Can anybody tell how I can get out of this?
Some code snippet
polylineOptions = new PolylineOptions();
foreach (var position in routeCoordinates)
{
polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
}
gMap.AddPolyline(polylineOptions);
Added on Sept 09, 2016
I started by using the points for the legs-steps, lots of points but wrong route, so I finally used only the final overview for the route this way
if (createRouteStep == true && prop.Equals("overview_polyline"))
{
i++;
line = getPropAndValue(lines[i]);
prop = getProp(line);
propValue = getPropValue(line);
string point = propValue.Replace(com, space).Trim();//= "yhoyHg~ol#nvgBgbjAbcbByxlDr_iArqG";
startRS = new RouteStep();
startRS.RouteID = routeCounter;
startRS.StepPoints = point;
sql.insertRouteStep(startRS);
i++;
}
The code is stored in an sqlite database, from which is later retrieved and decoded. Decoding works correct, I have tried a sample (points-result in the comment above) from the mentioned Google-test-site for this purpose and the route was the same as on the site. The points from my own request for the route have the correct direction, but don't follow any road or reach the destination at all.

Related

Sync to all CLs within a certain Date/Time range

My documentation and Google-fu is seriously failing me on this one, so:
how do I use P4API's GetChangelist() function to sync a range of files (i.e. all files from #now to #twoDaysAgo)? I can easily construct the command line to do this like so:
p4 changes -s submitted //...#2016/12/01,2016/12/06
but the API wants me to interface with the server via
GetChangelist(Options options, FileSpec[] files)
It's driving me crazy that I have to construct a combo of Options and Filespecs[] to make the request instead, and (AFAIK) can't just pass the actual command line string. Especially because all documentation seems to be non-existent.
Can somebody enlighten me as to what kind of filespec parameters I have to pass along? (I think that's what I need to use to specify the fact that I want to get a range of all CLs inside a certain time?) Thanks!
(As an aside: I was surprised there isn't a "P4API" tag yet, and I can't create one.)
And here's the non-command line version that you really want to use, from the Perforce documentation (once you find it :))
PathSpec path = new DepotPath("//depot/...");
DateTimeVersion lowerTimeStamp = new DateTimeVersion(new DateTime(2016,12,06));
DateTimeVersion upperTimeStamp = new DateTimeVersion(DateTime.Now);
VersionSpec version = new VersionRange(lowerTimeStamp, upperTimeStamp);
FileSpec[] fileSpecs = { new FileSpec(path, version) };
ChangesCmdOptions changeListOptions = new ChangesCmdOptions(ChangesCmdFlags.FullDescription | ChangesCmdFlags.IncludeTime, null, 0, ChangeListStatus.None, null);
IList<Changelist> changes = m_Repository.GetChangelists(changeListOptions, fileSpecs);
Alright, after a couple more hours of digging, I have found that there is a way to feed the actual command line parameters to the command. You create a DepotSpec, and then something like this is working for me to restrict the time range for CLs retrieved from the server:
ChangesCmdOptions changeListOptions = new ChangesCmdOptions(ChangesCmdFlags.FullDescription|ChangesCmdFlags.IncludeTime, null, 0, ChangeListStatus.None, null);
FileSpec[] fileSpecs = new FileSpec[1] { new FileSpec(new DepotPath("//depot/...#2016/12/05 21:57:30,#now"), null, null, null) };
IList<Changelist> changes = m_Repository.GetChangelists(changeListOptions, fileSpecs);
All this might be "indulgent smile" old news to people who've worked with the API for a while. It's just all a bit confusing to newcomers when documentation like the two pages mentioned in this post ("FileSpec object docs", "SyncFiles method docs") are offline now: Perforce Api - How to command "get revision [changelist number]"

OSMSharp - get informations about actual road

I am trying to code an app for Android (C# - Xamarin), and I loaded a PBF file, I can find route between two places (coordinates). But I dont know how can I get informations about place where I am actualy (by coordinates). I want to know something about road (street) where I am, for example street name, speed limit...
I did not found anything about this. I hope somebody knows how to do that.
DISCLAIMER: I'm the original author of OsmSharp/Itinero.
You can use this code to get info about an edge at a given location:
var routerDb = RouterDb.Deserialize(...); // load routerdb here.
var router = new Router(routerDb);
var routerPoint = router.Resolve(Vehicle.Car.Fastest(), new Coordinate(51.269692005119616f, 4.783473014831543f));
var edge = routerDb.Network.GetEdge(routerPoint.EdgeId);
var attributes = routerDb.GetProfileAndMeta(edge.Data.Profile, edge.Data.MetaId);
var speed = Vehicle.Car.Fastest().Speed(attributes);
The attributes are a collection of the orginal OSM tags, speed is a speed estimate for the Car profile.

Get URL Variables from a Frame and Pass to Codebehind

First off, yes I know I shouldn't be using frames, but I don't have a choice. It's an old system that's caused me nothing but headaches, but the network engineers love it and demand that this is where their information and pages have to go.
I'm currently using the .NET 4.0 framework, c#, and, though I doubt it matters for this question, SQL Server 2008R2.
The problem as it stands right now: I need a way to determine whether the primary or standby hardware is selected so I can properly set the radio button and initial information on page load to either the primary hardware or secondary hardware based on which page is loaded. The website my page is being used on is third party, which I do not have access to modifying, so I can't just tack URL variables onto that page or change settings.
The URL has variables, but they're generated statically elsewhere on the website and only visible inside the frame in which my page resides. I've never actually used frames, so I'm at a little bit of a loss. Worse, because of the way this is set up and being tested, I'm not actually sure how to set up any breakpoints in the code to see where it's failing.
I couldn't think of another way around this, but I would be more than happy to have a solution that doesn't involve this frame-y nonsense.
So far, I've been looking at these for guidance, but haven't had much success.
sharing variables between urls and frames, msdn's .NET 4.0 page on Frames,
a post on how to get url variables out of frames, and loading pages in IFrame dynamically from the codebehind.
For the time being, I've been asked to make sure the page as it stands does not break, which is why this is being checked instead of just done. It's currently in two places on that site, one without frames and URL variables (which the admins want to delete) and the new home with URL variables and frames. For now, the first one can't break, which is why you'll see a bit of strange checking and the ?? operator.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
System.Web.UI.HtmlControls.HtmlGenericControl orionIFrame =
(System.Web.UI.HtmlControls.HtmlGenericControl)this.FindControl("pcmaframe");
if (orionIFrame != null)
{
string frameURL = orionIFrame.Attributes["src"].ToString() ?? "";
Uri frameURI = new Uri(frameURL);
NameValueCollection queryVars = HttpUtility.ParseQueryString(frameURI.Query);
//If this is in Orion, we want to change the canceller to standby if it's 97, not 96
if (queryVars["NetObject"] == "N:97" || queryVars["NetObject"] == "N%3a97")
{
SelectCanceller.SelectedValue = "Standby";
primaryStandby = false;
}
}
//Do some other stuff to generate page data
Right now, the code that generates the frame looks like this (where [url] replaces the actual url and [mypage] replaces the actual file name I've used):
NodeID - ${NodeID}<br>
Node Name - ${NodeName}
<iframe id="pcmaframe" src="[url]/[mypage].aspx?NetObject=N:" + ${NodeID} width = 1000 height = 1500>
</iframe>
At the moment, there is no bad behavior, it simply fails to switch. Both pages display the primary, regardless of the URL variables. The primary being N:96 and the secondary being N:97. The reason I check is that I'd like it to display something in the event that it fails, so it defaults to the primary hardware.
So, wonderful Stack Overflow people... Can you answer any of my three questions?
How can I troubleshoot a Frame on a separate website without adding output to the page when I have no way to insert breakpoints?
What can I do instead of using the URL variables and messing with these frames?
What logic am I missing or screwing up in my code that's causing the frame to /not/ recognize the URL variable?
UPDATE
Well, so far, I've determined that the frame is null. Not sure if this is because of the this.FindControl is not being properly cast, or it's due to the way the website uses frames, or any number of other things...
After being allowed to add some debugging output to the page, I was able to find a work around. What I believe is happening, based on some testing and these articles:
FindControl() return null
Better way to find control in ASP.NET
http://msdn.microsoft.com/en-us/library/txxbk90b%28v=vs.90%29.aspx
http://forums.asp.net/t/1097333.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx
Is that the website where my program/page is being used has the frame at a higher level than my ASP has access to without a lot of technical voodoo. Since the frame wasn't returning, I started testing and found that the calling frame was actually using [URL].[MyPage].aspx?NetObject=N:97 as the previous page or the calling page. This was true under a variety of circumstances which meant it was semi-safe to use Request.UrlReferrer:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string frameURL = Request.UrlReferrer.ToString() ?? "NO DATA";
if ((frameURL != null) && (frameURL != "NO DATA"))
{
Uri frameURI = new Uri(frameURL);
NameValueCollection queryVars = HttpUtility.ParseQueryString(frameURI.Query);
//If this is in Orion, we want to change the canceller to standby if it's 97, not 96
if (queryVars["NetObject"] == "N:97" || queryVars["NetObject"] == "N%3a97")
{
SelectCanceller.SelectedValue = "Standby";
primaryStandby = false;
}
}

XNA 3.1 DrawUserPrimitives with Anti Aliasing - MultiSampling doesn't work?

So this is a continuation of a question I asked earlier today. I've built myself some nice looking ribbon trails using XNA 3.1's DrawUserPrimitives method, essentially by expanding a polygon as motion occurs. It all looks super sleek and nice, except for one thing - anti-aliasing. I cannot for the life of me work out how to apply it.
I've set this in the game constructor:
graphics.PreferMultiSampling = true;
And I've also added this to test for the hardware:
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>((sender, e) =>
{
PresentationParameters parameters = e.GraphicsDeviceInformation.PresentationParameters;
parameters.MultiSampleQuality = 0;
#if XBOX
pp.MultiSampleType = MultiSampleType.FourSamples;
return;
#else
int quality;
GraphicsAdapter adapter = e.GraphicsDeviceInformation.Adapter;
SurfaceFormat format = adapter.CurrentDisplayMode.Format;
if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.FourSamples, out quality))
{
parameters.MultiSampleType = MultiSampleType.FourSamples;
}
else if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.TwoSamples, out quality))
{
parameters.MultiSampleType = MultiSampleType.TwoSamples;
}
#endif
});
By adding some print lines, I know my hardware can support 4 sample AA, but this all seems to make no difference. I just can't seem to get this to work.
Here's a screenshot of one of my trails with all of that code applied:
I'd really appreciate some help. I looked at this a while ago for a solution to a different problem, and couldn't get it to work then, either.
Well, cheers.
Fixed this one, too!
The issue was that, while the back buffer was getting the right anti-alias settings, the render target wasn't. This meant that drawing to the render target was done without AA, but the texture that was then drawn to the back buffer was done with it. I've fixed it now.

CAD insert block with thumbnail under mouse

I need to insert an external DWG into an AutoCAD drawing via C# plugin.
I need to "ask" to the user the insertion point and rotation of the inserted block.
Until now I've always used a lisp function that calls the command "._-insert" which gives a thumbnail of the block under the mouse, allows the user to click into the drawing to set the insertion point and from that point allows the user to click one more time to set the rotation.
Now I want to avoid the use of Lisp or the use of low level API of AutoCAD because I need a solution that runs over various CAD environments.
What I found is something like this:
public static void InsertDwg(string dwgName)
{
CADAPI.ApplicationServices.Document doc = CADAPI.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
CADDB.Database db = doc.Database;
CADAPI.EditorInput.Editor ed = doc.Editor;
CADDB.ObjectId ObjId;
using (CADDB.Transaction trx = db.TransactionManager.StartTransaction())
{
CADDB.BlockTable bt = db.BlockTableId.GetObject(CADDB.OpenMode.ForRead) as CADDB.BlockTable;
CADDB.BlockTableRecord btrMs = bt[CADDB.BlockTableRecord.ModelSpace].GetObject(CADDB.OpenMode.ForWrite) as CADDB.BlockTableRecord;
using (CADDB.Database dbInsert = new CADDB.Database(false, true))
{
dbInsert.ReadDwgFile(dwgName, CADDB.FileOpenMode.OpenForReadAndAllShare, true, string.Empty);
ObjId = db.Insert(Path.GetFileNameWithoutExtension(dwgName), dbInsert, true);
}
CADAPI.EditorInput.PromptPointOptions ppo = new CADAPI.EditorInput.PromptPointOptions("\nInsertion Point");
CADAPI.EditorInput.PromptAngleOptions ppa = new CADAPI.EditorInput.PromptAngleOptions("\nInsert Rotation");
CADAPI.EditorInput.PromptPointResult ppr;
ppr = ed.GetPoint(ppo);
CADAPI.EditorInput.PromptDoubleResult ppd = ed.GetAngle(ppa);
if (ppr.Status == CADAPI.EditorInput.PromptStatus.OK)
{
CADGEOM.Point3d insertPt = ppr.Value;
CADDB.BlockReference bref = new CADDB.BlockReference(insertPt, ObjId);
btrMs.AppendEntity(bref);
trx.AddNewlyCreatedDBObject(bref, true);
trx.Commit();
}
}
}
But here I have two problems:
The main one is that there is no preview under the mouse.
The second is that the user needs to click 3 times instead of 2 to set both the insertion point and the rotation.
Is there any way that doesn't use some kind of SendCommand and does all of this stuff?
TIA
It seems Jigging is the way to go to allow the preview. I have three links for you.
Jigging multiple entities with the DrawJig
Using a jig to rotate an AutoCAD entity via .NET
Using transient graphics to simulate AutoCAD’s MOVE command using .NET
The first is an example of creating a simple jig with polylines - you could extend this to a block.
The second link is similar but applies rotation to the mix. This is applied to a rectangle but again could be modified to accomodate a block.
The third link describes a different method - AutoCADs transient graphics interface. You must be using AutoCAD 2009 or later to use this method.
The last two links are from the Through the Interface blog, where you may find some more examples and is a very good starting point if you have problems, especially for coding C#.
You will want to use the AcEdJig class. It provides the preview. You will have to write the code to collect the insert point and rotation and to transform the block accordingly.
Here is the first link from my google search for example usage code.

Categories

Resources