using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Windows;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
MySqlConnection connection;
MySqlDataAdapter adapter;
MySqlDataReader reader;
int circleRadius = 10;
MySql.Data.MySqlClient.MySqlConnection conn;
// string connectionString = "server=localhost;user id=Malsha;database=centraldbvol1;";
string myConnectionString = "server=localhost;uid=Malsha;" +
"pwd=sliit123;database=centraldbvol1;";
public Service()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public int getShopIdBySquareId(int x, int y)
{
string a = "-100";
int shopId = -1;
try
{
conn = new MySqlConnection(myConnectionString);
conn.Open();
string query = "select Shop_Id from vertualmap_relatedshop a where a.Square_Id_X=" + x.ToString() + " and a.Square_Id_Y=" + y.ToString() + ";";
MySqlCommand cmd = new MySqlCommand(query, conn);
reader = cmd.ExecuteReader();
while (reader.Read())
{//**assume 1 square id belongs to only 1 shop**
a = reader.GetInt32(0).ToString();
shopId = int.Parse(a);
//if (a.Equals("-100"))
// return -1;//if no result dnt come even inside
}
if (a.Equals("-100"))
return -1;//no shop
}
catch (MySqlException ex)
{
return -2;//execption
}
return shopId;
}
[WebMethod]
public List<int> getXYByAutoId(int autoId)
{
//workinggggggggggggggggggggggggggggggggggggggggggggggggg////////////////huraaaaaaaaaa
string a = "-100";
string b = "-100";
List<int> xy = new List<int>();
xy.Add(-100);
xy.Add(-100);
try
{
conn = new MySqlConnection(myConnectionString);
conn.Open();
string query = "select Square_Id_X,Square_Id_Y from vertualmap_relatedshop a where a.Auto_Id =" + autoId.ToString() + ";";
MySqlCommand cmd = new MySqlCommand(query, conn);
reader = cmd.ExecuteReader();
while (reader.Read())
{//**assume 1 square id belongs to only 1 shop**
a = reader.GetInt32(0).ToString();
b = reader.GetInt32(1).ToString();
xy[0]= int.Parse(a);
xy[1] = int.Parse(b);
//if (a.Equals("-100"))
// return -1;//if no result dnt come even inside
}
}
catch (MySqlException ex)
{
return xy;//execption
}
return xy;
}
[WebMethod]
public List<int> getStoredResultByInput(int autoId, double anglePoint1X, double anglePoint1Y, double anglePoint2X, double anglePoint2Y,double radius)
{
//workingggggggggggggggggggggggggggggggggggggggggggggg
string a = "-100";
string b = "-100";
List<int> xy = new List<int>();
xy[0] = -100;
xy[1] = -100;
try
{
conn = new MySqlConnection(myConnectionString);
conn.Open();
string query = "select Shop_Id,X,Length from ar_output a,ar_input b where a.Input_Id=b.Auto_Id AND Square_Id" + autoId.ToString() + " AND X1=" + anglePoint1X.ToString() + " AND Y1=" + anglePoint1Y.ToString() + " AND X2=" + anglePoint2X.ToString() + " AND Y2=" + anglePoint2Y.ToString() + " AND Radius=" + radius.ToString() + ";";
MySqlCommand cmd = new MySqlCommand(query, conn);
reader = cmd.ExecuteReader();
if (reader.Read())
{
while (reader.Read())
{//**assume 1 square id belongs to only 1 shop**
a = reader.GetInt32(0).ToString();
b = reader.GetInt32(1).ToString();
xy[0] = int.Parse(a);
xy[1] = int.Parse(b);
//if (a.Equals("-100"))
// return -1;//if no result dnt come even inside
}
}
else {
}
}
catch (MySqlException ex)
{
return xy;//execption
}
return xy;
}
/* A function to check whether point P(x, y) lies inside the triangle formed
by A(x1, y1), B(x2, y2) and C(x3, y3) */
[WebMethod]
public bool isInsideTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int x, int y)
{
bool response = false;
double A = calculateTriangleArea(x1, y1, x2, y2, x3, y3);
/* Calculate Area of triangle PBC */
double A1 = calculateTriangleArea(x, y, x2, y2, x3, y3);
/* Calculate area of triangle PAC */
double A2 = calculateTriangleArea(x1, y1, x, y, x3, y3);
/* Calculate area of triangle PAB */
double A3 = calculateTriangleArea(x1, y1, x2, y2, x, y);
double small = 0.001;
/* Check if sum of A1, A2 and A3 is same as A */
if (((A1 + A2 + A3) - A) <= small)
response = true;
else
response = false;
return response;
// return false;
}
/* A function to calculate area of triangle formed by (x1, y1),
(x2, y2) and (x3, y3) */
public double calculateTriangleArea(int x1, int y1, int x2, int y2, int x3, int y3)
{
return Math.Abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}
public class Shop
{
public int shopId;
public double x;
public double length;
public string comment;
public Shop() {
this.comment="Success";
}
public Shop(int id,double x,double length)
{
this.shopId = id;
this.x = x;
this.length = length;
}
}
public class ShopInsideTriangle
{
public int shopId;
public int noOfSquares;
public List<Square> Squares;
//double midPointX;
//double midPointY;
//double distance;
public Square midSquare;
public double minDistance;
public double minAngle;
public double maxAngle;
// public double relativeMinAngle;
//public double relativeMaxAngle;
public double angle;
public double midAngle;//mx mn
public ShopInsideTriangle(int shopId)
{
this.shopId = shopId;
this.Squares = new List<Square>();
this.noOfSquares = 0;
}
public void addSquare(Square square)
{
this.Squares.Add(square);
this.noOfSquares++;
}
//-------------------------------------------------
public void setMidSquare(double xo, double yo, double actualAngleTriLeft)
{
double midX = this.Squares.Sum(s => s.x);
double midY = this.Squares.Sum(s => s.y);
this.midSquare = new Square(midX, midY, xo, yo, actualAngleTriLeft);
}
public void setMinDistance()
{
this.minDistance= this.Squares.Max(s => s.distance);
}
public void setAngles(double xo, double yo, double actualAngleTriLeft)
{
this.maxAngle = this.Squares.Max(s => s.relativeAngle);
this.minAngle = this.Squares.Min(s => s.relativeAngle);
this.setAngle();
}
//------------------
public void setAngle()
{
this.angle = this.maxAngle - this.minAngle;
}
public void setMinAngle(double m)
{
this.minAngle = m;
setAngle();
}
public void setMaxAngle(double m)
{
this.maxAngle = m;
setAngle();
}
//double finalX;
//double finalLength;
//public List<Album> Albums;
// public string Name;
}
public class Square
{
public double x { get; set; }
public double y { get; set; }
public double distance;
public double actualAngle;
public double relativeAngle { get; set; }
public Square(double x, double y)
{
this.x = x;
this.y = y;
}
public Square(double x, double y, double xo, double yo, double actualAngleTriLeft)
{
this.x = x;
this.y = y;
this.calulateDistance(xo, yo);
this.calculateAngles(xo, yo, actualAngleTriLeft);
}
public void calulateDistance(double x1, double y1)
{
this.distance = Math.Abs(Math.Sqrt(x1 * x1 + y1 * y1));
}
//public void getAngleInBetween(double x1, double y1)
public void calculateAngles(double xo, double yo, double actualAngleTriLeft)
{
//const double Rad2Deg = 180.0 / Math.PI;
////const double Deg2Rad = Math.PI / 180.0;
//return Math.Atan2(y1 - y2, x2 - x1) * Rad2Deg;
double m = (yo - this.y) / (xo - this.x);
double angleInRadians = Math.Atan(m);
double angleInDegree = angleInRadians * (180 / Math.PI);
if (angleInDegree < 0)
{
this.actualAngle = angleInDegree + 360;
}
else
{
this.actualAngle = angleInDegree;
}
//---------------------
this.relativeAngle = actualAngleTriLeft - this.actualAngle;
}
}
//------------------------
[WebMethod]//workingggggggggg
public double getActualAngle(double x1, double y1, double x2, double y2)
{
//const double Rad2Deg = 180.0 / Math.PI;
////const double Deg2Rad = Math.PI / 180.0;
//return Math.Atan2(y1 - y2, x2 - x1) * Rad2Deg;
double m = (y1 - y2) / (x1 - x2);
double angleInRadians = Math.Atan(m);
double angleInDegree = angleInRadians * (180 / Math.PI);
if (angleInDegree < 0)
{
angleInDegree = angleInDegree + 360;
}
return angleInDegree;
}
[WebMethod]//workinggggggg
public double calulateDistance(double x1, double y1)
{
return Math.Abs(Math.Sqrt(x1 * x1 + y1 * y1));
}
//============================================================================================
[WebMethod]
public double AngleTesting(double x1, double y1)
{
//const double Rad2Deg = 180.0 / Math.PI;
double angleInRadians = Math.Atan(x1/y1);
double angleInDegree = angleInRadians * (180/Math.PI);
//const double Deg2Rad = Math.PI / 180.0;
return angleInDegree;
}
//-----------------------
// [WebMethod]
public double Hello(double x1, string y1)
{
//const double Rad2Deg = 180.0 / Math.PI;
// double angleInRadians = Math.Atan(x1 / y1);
// double angleInDegree = angleInRadians * (180 / Math.PI);
//const double Deg2Rad = Math.PI / 180.0;
// return angleInDegree;
return x1;
}
[WebMethod]
public Shop Hello1(Shop shop)
{
//const double Rad2Deg = 180.0 / Math.PI;
// double angleInRadians = Math.Atan(x1 / y1);
// double angleInDegree = angleInRadians * (180 / Math.PI);
//const double Deg2Rad = Math.PI / 180.0;
// return angleInDegree;
return shop;
}
}
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Windows;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
MySqlConnection connection;
MySqlDataAdapter adapter;
MySqlDataReader reader;
int circleRadius = 10;
MySql.Data.MySqlClient.MySqlConnection conn;
// string connectionString = "server=localhost;user id=Malsha;database=centraldbvol1;";
string myConnectionString = "server=localhost;uid=Malsha;" +
"pwd=sliit123;database=centraldbvol1;";
public Service()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public int getShopIdBySquareId(int x, int y)
{
string a = "-100";
int shopId = -1;
try
{
conn = new MySqlConnection(myConnectionString);
conn.Open();
string query = "select Shop_Id from vertualmap_relatedshop a where a.Square_Id_X=" + x.ToString() + " and a.Square_Id_Y=" + y.ToString() + ";";
MySqlCommand cmd = new MySqlCommand(query, conn);
reader = cmd.ExecuteReader();
while (reader.Read())
{//**assume 1 square id belongs to only 1 shop**
a = reader.GetInt32(0).ToString();
shopId = int.Parse(a);
//if (a.Equals("-100"))
// return -1;//if no result dnt come even inside
}
if (a.Equals("-100"))
return -1;//no shop
}
catch (MySqlException ex)
{
return -2;//execption
}
return shopId;
}
[WebMethod]
public List<int> getXYByAutoId(int autoId)
{
//workinggggggggggggggggggggggggggggggggggggggggggggggggg////////////////huraaaaaaaaaa
string a = "-100";
string b = "-100";
List<int> xy = new List<int>();
xy.Add(-100);
xy.Add(-100);
try
{
conn = new MySqlConnection(myConnectionString);
conn.Open();
string query = "select Square_Id_X,Square_Id_Y from vertualmap_relatedshop a where a.Auto_Id =" + autoId.ToString() + ";";
MySqlCommand cmd = new MySqlCommand(query, conn);
reader = cmd.ExecuteReader();
while (reader.Read())
{//**assume 1 square id belongs to only 1 shop**
a = reader.GetInt32(0).ToString();
b = reader.GetInt32(1).ToString();
xy[0]= int.Parse(a);
xy[1] = int.Parse(b);
//if (a.Equals("-100"))
// return -1;//if no result dnt come even inside
}
}
catch (MySqlException ex)
{
return xy;//execption
}
return xy;
}
[WebMethod]
public List<int> getStoredResultByInput(int autoId, double anglePoint1X, double anglePoint1Y, double anglePoint2X, double anglePoint2Y,double radius)
{
//workingggggggggggggggggggggggggggggggggggggggggggggg
string a = "-100";
string b = "-100";
List<int> xy = new List<int>();
xy[0] = -100;
xy[1] = -100;
try
{
conn = new MySqlConnection(myConnectionString);
conn.Open();
string query = "select Shop_Id,X,Length from ar_output a,ar_input b where a.Input_Id=b.Auto_Id AND Square_Id" + autoId.ToString() + " AND X1=" + anglePoint1X.ToString() + " AND Y1=" + anglePoint1Y.ToString() + " AND X2=" + anglePoint2X.ToString() + " AND Y2=" + anglePoint2Y.ToString() + " AND Radius=" + radius.ToString() + ";";
MySqlCommand cmd = new MySqlCommand(query, conn);
reader = cmd.ExecuteReader();
if (reader.Read())
{
while (reader.Read())
{//**assume 1 square id belongs to only 1 shop**
a = reader.GetInt32(0).ToString();
b = reader.GetInt32(1).ToString();
xy[0] = int.Parse(a);
xy[1] = int.Parse(b);
//if (a.Equals("-100"))
// return -1;//if no result dnt come even inside
}
}
else {
}
}
catch (MySqlException ex)
{
return xy;//execption
}
return xy;
}
/* A function to check whether point P(x, y) lies inside the triangle formed
by A(x1, y1), B(x2, y2) and C(x3, y3) */
[WebMethod]
public bool isInsideTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int x, int y)
{
bool response = false;
double A = calculateTriangleArea(x1, y1, x2, y2, x3, y3);
/* Calculate Area of triangle PBC */
double A1 = calculateTriangleArea(x, y, x2, y2, x3, y3);
/* Calculate area of triangle PAC */
double A2 = calculateTriangleArea(x1, y1, x, y, x3, y3);
/* Calculate area of triangle PAB */
double A3 = calculateTriangleArea(x1, y1, x2, y2, x, y);
double small = 0.001;
/* Check if sum of A1, A2 and A3 is same as A */
if (((A1 + A2 + A3) - A) <= small)
response = true;
else
response = false;
return response;
// return false;
}
/* A function to calculate area of triangle formed by (x1, y1),
(x2, y2) and (x3, y3) */
public double calculateTriangleArea(int x1, int y1, int x2, int y2, int x3, int y3)
{
return Math.Abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);
}
public class Shop
{
public int shopId;
public double x;
public double length;
public string comment;
public Shop() {
this.comment="Success";
}
public Shop(int id,double x,double length)
{
this.shopId = id;
this.x = x;
this.length = length;
}
}
public class ShopInsideTriangle
{
public int shopId;
public int noOfSquares;
public List<Square> Squares;
//double midPointX;
//double midPointY;
//double distance;
public Square midSquare;
public double minDistance;
public double minAngle;
public double maxAngle;
// public double relativeMinAngle;
//public double relativeMaxAngle;
public double angle;
public double midAngle;//mx mn
public ShopInsideTriangle(int shopId)
{
this.shopId = shopId;
this.Squares = new List<Square>();
this.noOfSquares = 0;
}
public void addSquare(Square square)
{
this.Squares.Add(square);
this.noOfSquares++;
}
//-------------------------------------------------
public void setMidSquare(double xo, double yo, double actualAngleTriLeft)
{
double midX = this.Squares.Sum(s => s.x);
double midY = this.Squares.Sum(s => s.y);
this.midSquare = new Square(midX, midY, xo, yo, actualAngleTriLeft);
}
public void setMinDistance()
{
this.minDistance= this.Squares.Max(s => s.distance);
}
public void setAngles(double xo, double yo, double actualAngleTriLeft)
{
this.maxAngle = this.Squares.Max(s => s.relativeAngle);
this.minAngle = this.Squares.Min(s => s.relativeAngle);
this.setAngle();
}
//------------------
public void setAngle()
{
this.angle = this.maxAngle - this.minAngle;
}
public void setMinAngle(double m)
{
this.minAngle = m;
setAngle();
}
public void setMaxAngle(double m)
{
this.maxAngle = m;
setAngle();
}
//double finalX;
//double finalLength;
//public List<Album> Albums;
// public string Name;
}
public class Square
{
public double x { get; set; }
public double y { get; set; }
public double distance;
public double actualAngle;
public double relativeAngle { get; set; }
public Square(double x, double y)
{
this.x = x;
this.y = y;
}
public Square(double x, double y, double xo, double yo, double actualAngleTriLeft)
{
this.x = x;
this.y = y;
this.calulateDistance(xo, yo);
this.calculateAngles(xo, yo, actualAngleTriLeft);
}
public void calulateDistance(double x1, double y1)
{
this.distance = Math.Abs(Math.Sqrt(x1 * x1 + y1 * y1));
}
//public void getAngleInBetween(double x1, double y1)
public void calculateAngles(double xo, double yo, double actualAngleTriLeft)
{
//const double Rad2Deg = 180.0 / Math.PI;
////const double Deg2Rad = Math.PI / 180.0;
//return Math.Atan2(y1 - y2, x2 - x1) * Rad2Deg;
double m = (yo - this.y) / (xo - this.x);
double angleInRadians = Math.Atan(m);
double angleInDegree = angleInRadians * (180 / Math.PI);
if (angleInDegree < 0)
{
this.actualAngle = angleInDegree + 360;
}
else
{
this.actualAngle = angleInDegree;
}
//---------------------
this.relativeAngle = actualAngleTriLeft - this.actualAngle;
}
}
//------------------------
[WebMethod]//workingggggggggg
public double getActualAngle(double x1, double y1, double x2, double y2)
{
//const double Rad2Deg = 180.0 / Math.PI;
////const double Deg2Rad = Math.PI / 180.0;
//return Math.Atan2(y1 - y2, x2 - x1) * Rad2Deg;
double m = (y1 - y2) / (x1 - x2);
double angleInRadians = Math.Atan(m);
double angleInDegree = angleInRadians * (180 / Math.PI);
if (angleInDegree < 0)
{
angleInDegree = angleInDegree + 360;
}
return angleInDegree;
}
[WebMethod]//workinggggggg
public double calulateDistance(double x1, double y1)
{
return Math.Abs(Math.Sqrt(x1 * x1 + y1 * y1));
}
//============================================================================================
[WebMethod]
public double AngleTesting(double x1, double y1)
{
//const double Rad2Deg = 180.0 / Math.PI;
double angleInRadians = Math.Atan(x1/y1);
double angleInDegree = angleInRadians * (180/Math.PI);
//const double Deg2Rad = Math.PI / 180.0;
return angleInDegree;
}
//-----------------------
// [WebMethod]
public double Hello(double x1, string y1)
{
//const double Rad2Deg = 180.0 / Math.PI;
// double angleInRadians = Math.Atan(x1 / y1);
// double angleInDegree = angleInRadians * (180 / Math.PI);
//const double Deg2Rad = Math.PI / 180.0;
// return angleInDegree;
return x1;
}
[WebMethod]
public Shop Hello1(Shop shop)
{
//const double Rad2Deg = 180.0 / Math.PI;
// double angleInRadians = Math.Atan(x1 / y1);
// double angleInDegree = angleInRadians * (180 / Math.PI);
//const double Deg2Rad = Math.PI / 180.0;
// return angleInDegree;
return shop;
}
}
No comments:
Post a Comment