• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Simplest C# console app to access a web site text? [duplicate]

How to get the HTML code from a website, save it, and find some text by a LINQ expression?

I'm using the following code to get the source of a web page:

public static String code(string Url) {     HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(Url);     myRequest.Method = "GET";     WebResponse myResponse = myRequest.GetResponse();     StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8);     string result = sr.ReadToEnd();     sr.Close();     myResponse.Close();      return result;  } 

How do I find the text in a div in the source of the web page?

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]

Are there any more specific details on the kind of distortion? If, for example, your latitudes and longitudes are "distorted" onto your 2D map using a Mercator projection, the conversion math is readily available.

If the map is distorted truly arbitrarily, there are lots of things you could try, but the simplest would probably be to compute a weighted average from your existing point mappings. Your weights could be the squared inverse of the x/y distance from your new point to each of your existing points.

Some pseudocode:

estimate-latitude-longitude (x, y)      numerator-latitude := 0     numerator-longitude := 0     denominator := 0      for each point,         deltaX := x - point.x         deltaY := y - point.y         distSq := deltaX * deltaX + deltaY * deltaY         weight := 1 / distSq          numerator-latitude += weight * point.latitude         numerator-longitude += weight * point.longitude         denominator += weight      return (numerator-latitude / denominator, numerator-longitude / denominator) 

This code will give a relatively simple approximation. If you can be more precise about the way the projection distorts the geographical coordinates, you can probably do much better.

see demo
  • 468
Reply Report

Alright. From a theoretical point of view, given that the distortion is "arbitrary", and any solution requires you to model this arbitrary distortion, you obviously can't get an "answer". However, any solution is going to involve imposing (usually implicitly) some model of the distortion that may or may not reflect the reality of the situation.

Since you seem to be most interested in models that presume some sort of local continuity of the distortion mapping, the most obvious choice is the one you've already tried: linear interpolaton between the nearest points. Going beyond that is going to require more sophisticated mathematical and numerical analysis knowledge.

You are incorrect, however, in presuming you cannot expand this to more points. You can by using a least-squared error approach. Find the linear answer that minimizes the error of the other points. This is probably the most straight-forward extension. In other words, take the 5 nearest points and try to come up with a linear approximation that minimizes the error of those points. And use that. I would try this next.

If that doesn't work, then the assumption of linearity over the area of N points is broken. At that point you'll need to upgrade to either a quadratic or cubic model. The math is going to get hectic at that point.

demo
  • 6
Reply Report

the problem is that the sphere can be distorted a number of ways, and having all those points known on the equator, lets say, wont help you map points further away.

You need better 'close' points, then you can assume these three points are on a plane with the fourth and do the interpolation --knowing that the distance of longitudes is a function, not a constant.

  • 455
Reply Report

Ummm. Maybe I am missing something about the question here, but if you have long/lat info, you also have the direction of north?

It seems you need to map geodesic coordinates to a projected coordinates system. For example osgb to wgs84.

The maths involved is non-trivial, but the code comes out a only a few lines. If I had more time I'd post more but I need a shower so I will be boring and link to the wikipedia entry which is pretty good.

Note: Post shower edited.

  • 33
Reply Report

Are there any more specific details on the kind of distortion? If, for example, your latitudes and longitudes are "distorted" onto your 2D map using a Mercator projection, the conversion math is readily available.

If the map is distorted truly arbitrarily, there are lots of things you could try, but the simplest would probably be to compute a weighted average from your existing point mappings. Your weights could be the squared inverse of the x/y distance from your new point to each of your existing points.

Some pseudocode:

estimate-latitude-longitude (x, y)      numerator-latitude := 0     numerator-longitude := 0     denominator := 0      for each point,         deltaX := x - point.x         deltaY := y - point.y         distSq := deltaX * deltaX + deltaY * deltaY         weight := 1 / distSq          numerator-latitude += weight * point.latitude         numerator-longitude += weight * point.longitude         denominator += weight      return (numerator-latitude / denominator, numerator-longitude / denominator) 

This code will give a relatively simple approximation. If you can be more precise about the way the projection distorts the geographical coordinates, you can probably do much better.

  • 5
Reply Report