Displaying a polyline of geocoordinate objects - windows-phone-7

I have a bunch of GeoCoordinate objects that I wish to display as a polyline (to show a path a person has taken).
My unsuccessful attempt (Does not display any line):
var map = new Map(); // Nokia Maps
var layer = new MapLayer();
var overlay = new MapOverlay();
var polyline = new MapPolyline();
var gc = new GeoCoordinateCollection();
foreach(var geo in MyGeoCoordinateList) {
gc.Add(geo);
}
polyline.Path = gc;
polyline.StrokeColors = Colors.Red;
polyline.StrokeThickness = 3;
overlay.Content = polyline;
layer.Add(overlay);
map.Layers.Add(layer);
LayoutRoot.Children.Add(map);

It turns out that to display a path (which simply connects points and does not follow roads like in Mike Brown's example) you need to add the polyline to a MapElements object, i.e:
var map = new Map(); // Nokia Maps
var polyline = new MapPolyline();
var gc = new GeoCoordinateCollection();
foreach(var geo in MyGeoCoordinateList) {
gc.Add(geo);
}
polyline.Path = gc;
polyline.StrokeColors = Colors.Red;
polyline.StrokeThickness = 3;
map.MapElements.Add(polyline);
LayoutRoot.Children.Add(map);
As a bonus here's how to set the map so it contains the points in the view port (with nice animation):
map.SetView(LocationRectangle.CreateBoundingRectangle(MyGeoCoordinateList, MapAnimationKind.Parabolic);

I wanted to do the same thing, I used a GeoQuery passing in all of the waypoints. The query generated a route that I then displayed on the UI.
var query = new RouteQuery();
query.Waypoints = new[]
{
new GeoCoordinate(40.7840553533410,-73.9764425910787),
new GeoCoordinate(40.7833068308611,-73.9745997113487),
new GeoCoordinate(40.7826229881351,-73.9730985576614),
new GeoCoordinate(40.7821147220884,-73.9719513345183),
new GeoCoordinate(40.7809503161196,-73.9724639235822),
new GeoCoordinate(40.7803311395532,-73.9721954245488),
new GeoCoordinate(40.7795640919224,-73.9729398991417),
};
query.TravelMode = TravelMode.Walking;
var result = await query.GetRouteAsync();
var mapRoute = new MapRoute(result);
mapRoute.Color = Colors.Magenta;
mainMap.AddRoute(mapRoute);
mainMap is the Map control in my UI. The query creates a route that follows the available path (since I marked it as a walking path, it used the foot paths in central park).

Related

an error when I used ammo.js and physi.js , what should I do for it?

I want to use Physi.js to make a car , but there has some error, I view my demo at Chrome, and I don't know the error is caused by the file named ammo.js or physi.js ,and following are my codes:
var phymaterial = Physijs.createMaterial(new THREE.MeshStandardMaterial({color:0xff0000,wireframe:true}),0,1);
//create a wall
var wall1 = new Physijs.BoxMesh(new THREE.CubeGeometry(50,10,2),meshGray);
wall1.position.set(0,5,35);
scene.add(wall1);
var cubegeo = new THREE.CubeGeometry(31.6,6,13.6);
//create a cube as car's body
var carPhy = new Physijs.BoxMesh(cubegeo,phymaterial,0);
carPhy.position.set(0,5,0)
car.position.set(0.6,-3,0)
scene.add(carPhy);
//create four wheels use Physijs
var wheelfl = new Physijs.CylinderMesh(new THREE.CylinderGeometry(4,4,1,30),phymaterial,100);
wheelfl.rotation.x = Math.PI/2;
wheelfl.position.set(10,4,-8)
scene.add(wheelfl);
var wheelfr = new Physijs.CylinderMesh(new THREE.CylinderGeometry(4,4,1,30),phymaterial,100);
wheelfr.rotation.x = Math.PI/2;
wheelfr.position.set(10,4,8)
scene.add(wheelfr);
var wheelbl = new Physijs.CylinderMesh(new THREE.CylinderGeometry(4,4,1,30),phymaterial,100);
wheelbl.rotation.x = Math.PI/2;
wheelbl.position.set(-10,4,-8)
scene.add(wheelbl);
var wheelbr = new Physijs.CylinderMesh(new THREE.CylinderGeometry(4,4,1,30),phymaterial,100);
wheelbr.rotation.x = Math.PI/2;
wheelbr.position.set(-10,4,8)
scene.add(wheelbr);
//create constraint with Physijs.DOFConstraint
var fl = new Physijs.DOFConstraint(wheelfl,carPhy,new THREE.Vector3(10,4,-10));
scene.addConstraint(fl);
var fr = new Physijs.DOFConstraint(wheelfr,carPhy,new THREE.Vector3(10,4,10));
scene.addConstraint(fr);
var bl = new Physijs.DOFConstraint(wheelbl,carPhy,new THREE.Vector3(-10,4,-10));
scene.addConstraint(bl);
var br = new Physijs.DOFConstraint(wheelbr,carPhy,new THREE.Vector3(-10,4,10));
scene.addConstraint(br);
And the error information like following:
Uncaught ReferenceError: _emscripten_bind_btGeneric6DofConstraint_btGeneric6DofConstraint_4 is not defined
at new btGeneric6DofConstraint (ammo.js:22)
at Object.public_functions.addConstraint (physijs_worker.js:873)
at self.onmessage (physijs_worker.js:1412)
I wanna know how can I resolve it?

OPserver: SQL CPU Graph Not Displayed

i am using opserver tool to monitor SQL performance everything works fine except it is not display CPU graph sparks for both standalone and cluster
i replace SQLCPUSpark function with this code
public ActionResult SQLCPUSpark(string node)
{
var instance = SQLInstance.Get(node);
if (instance == null)
return ContentNotFound("SQLNode not found with name = '" + node + "'");
var dataPoints = instance.CPUHistoryLastHour;
var chart = new Chart();
var area = new ChartArea();
area.AxisX.Enabled = AxisEnabled.False;
area.AxisY.Enabled = AxisEnabled.False;
area.AxisY.Maximum = 100;
// configure your chart area (dimensions, etc) here.
chart.ChartAreas.Add(area);
// create and customize your data series.
var series = new Series();
foreach (var item in dataPoints.Data)
{
series.Points.AddXY(item.EventTime.ToOADate(), item.ProcessUtilization);
}
series.Label = "";
series.Font = new Font("Segoe UI", 8.0f, FontStyle.Bold);
series.ChartType = SeriesChartType.Area;
chart.Series.Add(series);
return chart.ToResult();
}

How can I add disparate chunks to a PdfPCell using iTextSharp?

How can I concatenate disparate chunks and add them to a paragraph, the paragraph to a cell, then the cell to a table using iTextSharp (in generating a PDF file)?
I am able to get to a certain "place" in my PDF file generation, so that it looks like so (the right side of the page is blank, as it should be):
This is the code I'm using for that:
using (var ms = new MemoryStream())
{
using (var doc = new Document(PageSize.A4, 50, 50, 25, 25))
{
//Create a writer that's bound to our PDF abstraction and our stream
using (var writer = PdfWriter.GetInstance(doc, ms))
{
//Open the document for writing
doc.Open();
var courierBold11Font = FontFactory.GetFont(FontFactory.COURIER_BOLD, 11, BaseColor.BLACK);
var docTitle = new Paragraph("Mark Twain", courierBold11Font);
doc.Add(docTitle);
var timesRoman9Font = FontFactory.GetFont("Times Roman", 9, BaseColor.BLACK);
var subTitle = new Paragraph("Roughing It", timesRoman9Font);
doc.Add(subTitle);
var courier9RedFont = FontFactory.GetFont("Courier", 9, BaseColor.RED);
var importantNotice = new Paragraph("'All down but nine; set 'em up on the other alley, pard' - Scotty Briggs", courier9RedFont);
importantNotice.Leading = 0;
importantNotice.MultipliedLeading = 0.9F; // reduce the width between lines in the paragraph with these two settings
PdfPTable table = new PdfPTable(1);
PdfPCell cellImportantNote = new PdfPCell(importantNotice);
cellImportantNote.BorderWidth = PdfPCell.NO_BORDER;
table.WidthPercentage = 50;
table.HorizontalAlignment = Element.ALIGN_LEFT;
table.AddCell(cellImportantNote);
doc.Add(table);
doc.Close();
}
var bytes = ms.ToArray();
String PDFTestOutputFileName = String.Format("iTextSharp_{0}.pdf", DateTime.Now.ToShortTimeString());
PDFTestOutputFileName = PDFTestOutputFileName.Replace(":", "_");
var testFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), PDFTestOutputFileName);
File.WriteAllBytes(testFile, bytes);
MessageBox.Show(String.Format("{0} written", PDFTestOutputFileName));
}
}
However, I need to break up the red text so that part of it is bolded, parts of it are anchor tags/hrefs, etc.
I thought I could do it this way:
var courier9RedBoldFont = FontFactory.GetFont(FontFactory.COURIER_BOLD, 9, BaseColor.RED);
// Build up chunkified version of "important notice"
Chunk boldpart = new Chunk("All down but nine - set 'em up on the other alley, pard", courier9RedBoldFont);
Chunk attribution = new Chunk("Scotty Briggs", courier9RedFont);
PdfPTable tbl = new PdfPTable(1);
tbl.WidthPercentage = 50;
tbl.HorizontalAlignment = Element.ALIGN_LEFT;
var par = new Paragraph();
par.Chunks.Add(boldpart);
par.Chunks.Add(attribution );
PdfPCell chunky = new PdfPCell(par);
chunky.BorderWidth = PdfPCell.NO_BORDER;
tbl.AddCell(chunky);
doc.Add(tbl);
...but that's not adding anything at all to the PDF file, but why not? Doesn't a cell take a paragraph, and cannot a paragraph be comprised of Chunks?
Instead of para.Chunks.Add() just use par.Add(); The Chunks that are returned from Paragraph actually come from the base class Phrase. If you look at the code for that property you'll see that the collection returned is actually a temporary collection created on the fly so it is effectively read-only.

Updating Panel with new values in GAS UI

I have a huge spreadsheet matrix, from which I create a long list of check boxes. The users then select different abilities, press search. The code the cross-checks with the database spreadsheet, returning names of the persons who has those abilities.
I need to update the "rightPanel" with the results of my search. But i simple can't figure out how to - if at all posible - update a panel in my UI..
var dataSSkey = 'sheetID'; //datasheet ID
var dataSheet = SpreadsheetApp.openById(dataSSkey).getSheetByName('Ansatte');
var groupsArray = [[],[],[],[]];
var lastRow = dataSheet.getLastRow();
var lastColumn = dataSheet.getLastColumn();
var dataArray = dataSheet.getRange(1,1,lastRow,lastColumn).getValues();
var numberGroups
var app = UiApp.createApplication().setTitle('Find Consultant');
var panel = app.createVerticalPanel();
var leftPanel = app.createVerticalPanel().setWidth(450);
var rightPanel = app.createVerticalPanel().setWidth(450);
var grid = app.createGrid(1, 2).setId('myGrid')
var outputArray = []; //to store output from search
var positiveList = [[],[]]; //array to store name and folder-ID of consultants matching
var numberPositive = 0; //number of consultants matching
function doGet() {
buildGroupsArray()
addCheckBoxesToUI()
var scrollPanel = app.createScrollPanel().setHeight(460);
//Search button
var searchButton = app.createButton('Search');
var clickHandler = app.createServerClickHandler("respondToSearch");
searchButton.addClickHandler(clickHandler);
clickHandler.addCallbackElement(panel);
var spacerImage = app.createImage("http://www.bi..ge.jpg").setHeight(3);
scrollPanel.add(panel);
rightPanel.add(app.createLabel('resultat her'));
leftPanel.add(scrollPanel);
leftPanel.add(spacerImage);
leftPanel.add(searchButton);
grid.setWidget(0, 0, leftPanel)
grid.setWidget(0, 1, rightPanel);
app.add(grid);
return app;
}
function respondToSearch(e){
var numberLogged = 0;
//define firstEmpty
var firstEmpty = "A"+lastRow;
if(lastRow !== 1){
firstEmpty = "A"+(lastRow+1);
};
//find selected competencies --> store in array + count competencies
for(i = 1; i <= lastRow; i++){
if (e.parameter["Checkbox"+i] == "true") {
var value = e.parameter["CheckboxValue"+i];
outputArray[numberLogged] = value;
numberLogged++;
}
}
for(i = 2; i <= lastColumn; i++){
var numberCorrect = 0;
//Run through rows according to content of output from selection
for(j in outputArray){
//Check if consultant own selected competency
if(dataArray[outputArray[j]][i] == "x"){
numberCorrect++; //if consultant owns selected competency then count
}
}
//if consultant owns all competencies, then add name and folder-id to array
if(numberCorrect == numberLogged){
positiveList[0][numberPositive] = dataArray[1][i]; //Add consultant name
positiveList[1][numberPositive] = dataArray[2][i]; //Add consultant-folder ID
numberPositive++ //count the number of consultants that own all competencies
}
}
for(j in positiveList[0]){
var name = positiveList[0][j];
var id = positiveList[1][j];
Logger.log(name);
Logger.log(id)
var anchor = app.createAnchor(name,'https://ww......folderviewid='+id);
rightPanel.add(anchor)
}
return app;
}
I don't really understand the problem you have...
In your handler function you only have to use app=UiApp.getActiveApplication() and from there populate the panel exactly the same way you did it in the doGet() function, ending with a return app; that will actually update the current Ui.
There are dozens of examples all around... did I misunderstand something in your question ?
Edit : following your comment.
I suppose you defined your variables outside of the doGet function hoping they will become global and so available to all the functions in your script but this is not going to work. Global variables in Google Apps script can't be updated by functions.
I would strongly recommend that you create app and panels in the doGet function and give them an ID so that you can get them back and update their values (or content) from the handler functions.
Here is a re-written version of your code (didn't test)
: (some parts are not reproduced (see //...)
var dataSSkey = 'sheetID'; //datasheet ID
var dataSheet = SpreadsheetApp.openById(dataSSkey).getSheetByName('Ansatte');
var groupsArray = [[],[],[],[]];
var lastRow = dataSheet.getLastRow();
var lastColumn = dataSheet.getLastColumn();
var dataArray = dataSheet.getRange(1,1,lastRow,lastColumn).getValues();
var numberGroups
var outputArray = []; //to store output from search
var positiveList = [[],[]]; //array to store name and folder-ID of consultants matching
var numberPositive = 0; //number of consultants matching
function doGet() {
var app = UiApp.createApplication().setTitle('Find Consultant');
var panel = app.createVerticalPanel();
var leftPanel = app.createVerticalPanel().setWidth(450).setId('leftPanel');
var rightPanel = app.createVerticalPanel().setWidth(450).setId('rightPanel');;
var grid = app.createGrid(1, 2).setId('myGrid')
buildGroupsArray(app); // in this function get app as parameter or use UiApp.getActiveApplication();
addCheckBoxesToUI(app);// in this function get app as parameter or use UiApp.getActiveApplication();
var scrollPanel = app.createScrollPanel().setHeight(460);
//...
//...
return app;
}
function respondToSearch(e){
//...
//...
var app = UiApp.getActiveApplication();
var rightPanel = app.getElementById('rightPanel');
for(j in positiveList[0]){
var name = positiveList[0][j];
var id = positiveList[1][j];
Logger.log(name);
Logger.log(id)
var anchor = app.createAnchor(name,'https://ww......folderviewid='+id);
rightPanel.add(anchor)
}
return app;
}

OSMF PLAYER with 4 videos and 1 control bar

I have a requirement where i need to show 4 contents of video playing parallely i achieved it through parallel element but here the main challange is that i want to show all the 4 videos in different panels and a common controlbar to play/pause the video.
When i am trying to add the mediaplayer as Uicomponent to hbox/vbox its throwing runtime exception.
Please help me.
protected function initPlayer():void
{
// Create a mediafactory instance
var leftcontainer:Panel = new Panel();
leftcontainer.percentHeight=50;
leftcontainer.percentWidth=50;
mediaFactory = new DefaultMediaFactory();
//Marker 1: Create a LayoutMetaData object stup up to even out the 2 parellel streams initially
var layoutData:LayoutMetadata = new LayoutMetadata();
layoutData.percentWidth = 50;
layoutData.percentHeight = 50;
layoutData.scaleMode = ScaleMode.LETTERBOX;
//Marker 2: Create the left side Media Element to play the LOGO_VID and apply the meta-data
var leftElement:MediaElement = mediaFactory.createMediaElement( new URLResource( LOGO_VID ) );
leftElement.metadata.addValue( LayoutMetadata.LAYOUT_NAMESPACE, layoutData );
//Marker 3: Create the right side Media Element to play the STREAMING_PATH and apply the meta-data
var rightElement:MediaElement = mediaFactory.createMediaElement( new URLResource( STREAMING_PATH ) );
rightElement.metadata.addValue( LayoutMetadata.LAYOUT_NAMESPACE, layoutData );
//Marker 4: Create the ParallelElement and add the left and right elements to it
var parallelElement:ParallelElement = new ParallelElement();
parallelElement.addChild( leftElement );
parallelElement.addChild( rightElement );
//Marker 5: Reinstantiate the layoutData to clear it out and set the layout data for the parallel element
layoutData = new LayoutMetadata();
layoutData.layoutMode = LayoutMode.HORIZONTAL;
layoutData.horizontalAlign = HorizontalAlign.CENTER;
layoutData.verticalAlign = VerticalAlign.MIDDLE;
layoutData.width = 800;
layoutData.height = 600;
parallelElement.metadata.addValue( LayoutMetadata.LAYOUT_NAMESPACE, layoutData );
//the simplified api controller for media
player = new MediaPlayer( parallelElement );
//the container (sprite) for managing display and layout
container = new MediaContainer();
container.addMediaElement( parallelElement );
//Adds the container to the stage
var ui:UIComponent = new UIComponent();
ui.addChild(container as DisplayObject);
leftcontainer.addElement(ui);
this.addChild(container);
}
You can download the OSMF trunk and there are samples folder in
which a project ExamplePlayer is there in which many different
way to playing video. The following code is extracted from there
var parallelElement:SynchronizedParallelElement = new SynchronizedParallelElement();
var layout:LayoutMetadata = new LayoutMetadata();
layout.horizontalAlign = HorizontalAlign.CENTER;
layout.verticalAlign = VerticalAlign.MIDDLE;
parallelElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
var mediaElement1:MediaElement = new VideoElement(new URLResource(REMOTE_PROGRESSIVE));
layout = new LayoutMetadata();
layout.left = 0;
layout.top = 0;
layout.percentWidth = 50;
layout.percentHeight = 50;
mediaElement1.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
parallelElement.addChild(mediaElement1);
var mediaElement2:MediaElement = new VideoElement(new URLResource(REMOTE_STREAM));
layout = new LayoutMetadata();
layout.left = 0;
layout.bottom = 0;
layout.percentWidth = 50;
layout.percentHeight = 50;
mediaElement2.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
parallelElement.addChild(mediaElement2);
var mediaElement3:MediaElement = new VideoElement(new URLResource(REMOTE_STREAM));
layout = new LayoutMetadata();
layout.right = 0;
layout.top = 0;
layout.percentWidth = 50;
layout.percentHeight = 50;
mediaElement3.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
parallelElement.addChild(mediaElement3);
var mediaElement4:MediaElement = new VideoElement(new URLResource(REMOTE_PROGRESSIVE2));
layout = new LayoutMetadata();
layout.right = 0;
layout.bottom = 0;
layout.percentWidth = 50;
layout.percentHeight = 50;
mediaElement4.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout);
parallelElement.addChild(mediaElement4);
return parallelElement;
Try this you will get the 4 video playing or download the sample and use the FlashBuilder to run the project.

Resources