Search Results

Search found 5784 results on 232 pages for 'points'.

Page 59/232 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • LINQ Query using UDF that receives parameters from the query

    - by Ben Fidge
    I need help using a UDF in a LINQ which calculates a users position from a fixed point. int pointX = 567, int pointY = 534; // random points on a square grid var q = from n in _context.Users join m in _context.GetUserDistance(n.posY, n.posY, pointX, pointY, n.UserId) on n.UserId equals m.UserId select new User() { PosX = n.PosX, PosY = n.PosY, Distance = m.Distance, Name = n.Name, UserId = n.UserId }; The GetUserDistance is just a UDF that returns a single row in a TVP with that users distance from the points deisgnated in pointX and pointY variables, and the designer generates the following for it: [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetUserDistance", IsComposable=true)] public IQueryable<GetUserDistanceResult> GetUserDistance([global::System.Data.Linq.Mapping.ParameterAttribute(Name="X1", DbType="Int")] System.Nullable<int> x1, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="X2", DbType="Int")] System.Nullable<int> x2, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Y1", DbType="Int")] System.Nullable<int> y1, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Y2", DbType="Int")] System.Nullable<int> y2, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="UserId", DbType="Int")] System.Nullable<int> userId) { return this.CreateMethodCallQuery<GetUserDistanceResult>(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), x1, x2, y1, y2, userId); } when i try to compile i get The name 'n' does not exist in the current context

    Read the article

  • Message queue proxy in Python + Twisted

    - by gasper_k
    Hi, I want to implement a lightweight Message Queue proxy. It's job is to receive messages from a web application (PHP) and send them to the Message Queue server asynchronously. The reason for this proxy is that the MQ isn't always avaliable and is sometimes lagging, or even down, but I want to make sure the messages are delivered, and the web application returns immediately. So, PHP would send the message to the MQ proxy running on the same host. That proxy would save the messages to SQLite for persistence, in case of crashes. At the same time it would send the messages from SQLite to the MQ in batches when the connection is available, and delete them from SQLite. Now, the way I understand, there are these components in this service: message listener (listens to the messages from PHP and writes them to a Incoming Queue) DB flusher (reads messages from the Incoming Queue and saves them to a database; due to SQLite single-threadedness) MQ connection handler (keeps the connection to the MQ server online by reconnecting) message sender (collects messages from SQlite db and sends them to the MQ server, then removes them from db) I was thinking of using Twisted for #1 (TCPServer), but I'm having problem with integrating it with other points, which aren't event-driven. Intuition tells me that each of these points should be running in a separate thread, because all are IO-bound and independent of each other, but I could easily put them in a single thread. Even though, I couldn't find any good and clear (to me) examples on how to implement this worker thread aside of Twisted's main loop. The example I've started with is the chatserver.py, which uses service.Application and internet.TCPServer objects. If I start my own thread prior to creating TCPServer service, it runs a few times, but the it stops and never runs again. I'm not sure, why this is happening, but it's probably because I don't use threads with Twisted correctly. Any suggestions on how to implement a separate worker thread and keep Twisted? Do you have any alternative architectures in mind?

    Read the article

  • BackgroundWorker and instance variables

    - by Alastair Pitts
    One thing that's always confused me is how a BackgroundWorker seems to have thread-safe access to the instance variables of the surrounding class. Given a basic class: public class BackgroundProcessor { public List<int> Items { get; private set; } public BackgroundProcessor(IEnumerable<int> items) { Items = new List<int>(items); } public void DoWork() { BackgroundWorker worker = new BackgroundWorker(); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.DoWork += new DoWorkEventHandler(worker_DoWork); worker.RunWorkerAsync(); } void worker_DoWork(object sender, DoWorkEventArgs e) { var processor = new ProcessingClass(); processor.Process(this.Points); //Accessing the instance variable } void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { //Stuff goes here } } Am I erroneous in my assumption the the call to processor.Process(this.Points); is a thread-safe call? How don't I get a cross-thread access violation? I'm sure it's obvious, but it always has confused me.

    Read the article

  • Programmatically creating a clickable area on an image.

    - by Thomas Stock
    Hi, I'm trying to create "imagemaps" on an image in wpf using codebehind. See the following XML: <Button Type="Area"> <Point X="100" Y="100"></Point> <Point X="100" Y="200"></Point> <Point X="200" Y="200"></Point> <Point X="200" Y="100"></Point> <Point X="150" Y="150"></Point> </Button> I'm trying to translate this to a button on a certain image in my WPF app. I've already did a part of this, but I'm stuck at setting the Polygon as the button's "template": private Button GetAreaButton(XElement buttonNode) { // get points PointCollection buttonPointCollection = new PointCollection(); foreach (var pointNode in buttonNode.Elements("Point")) { buttonPointCollection.Add(new Point((int)pointNode.Attribute("X"), (int)pointNode.Attribute("Y"))); } // create polygon Polygon myPolygon = new Polygon(); myPolygon.Points = buttonPointCollection; myPolygon.Stroke = Brushes.Yellow; myPolygon.StrokeThickness = 2; // create button based on polygon Button button = new Button(); ????? } I'm also unsure on how to add/remove this button to/from my image, but I'm looking into that. Any help is appreciated.

    Read the article

  • A weird crash...

    - by Nima
    Hi, I have a piece of code that runs in debug mode in VS2008, C++. The problem is that when I am debugging the code line by line, at a very weird point of the code, it crashes and says: debug assertion faild. Expression: _BLOCK_TYPE_IS_VALID(pHead-nBlockUse) The crash point is on the first closed curly bracket (after mesh-edges[e].needsUpdate=false;) I don't understand why on a curly bracket? does that make sense to you guys? Can anybody help me understanding what is going on..? for(int e=0; e<mesh->edges.size(); e++) { if(mesh->edges[e].valid && mesh->edges[e].v[0]>=0 && mesh->edges[e].v[1]>=0 && mesh->points[mesh->edges[e].v[0]].writable && mesh->points[mesh->edges[e].v[1]].writable) { //update v_hat and its corresponding error DecEdge Current = DecEdge(e); pair<Point, float> ppf = computeVhat(e); Current.v_hat = ppf.first; Current.error = ppf.second; edgeSoup.push(Current); mesh->edges[e].needsUpdate=false; } }

    Read the article

  • Simulating 3D 'cards' with just orthographic rendering

    - by meds
    I am rendering textured quads from an orthographic perspective and would like to simulate 'depth' by modifying UVs and the vertex positions of the quads four points (top left, top right, bottom left, bottom right). I've found if I make the top left and bottom right corners y position be the same I don't get a linear 'skew' but rather a warped one where the texture covering the top triangle (which makes up the quad) seems to get squashed while the bottom triangles texture looks normal. I can change UVs, any of the four points on the quad (but only in 2D space, it's orthographic projection anyway so 3D space won't matter much). So basically I'm trying to simulate perspective on a two dimensional quad in orthographic projection, any ideas? Is it even mathematically possible/feasible? ideally what I'd like is a situation where I can set an x/y rotation as well as a virtual z 'position' (which simulates z depth) through a function and see it internally calclate the positions/uvs to create the 3D effect. It seems like this should all be mathematical where a set of 2D transforms can be applied to each corner of the quad to simulate depth, I just don't know how to make it happen. I'd guess it requires trigonometry or something, I'm trying to crunch the math but not making much progress. here's what I mean: Top left is just the card, center is the card with a y rotation of X degrees and right most is a card with an x and y rotation of different degrees.

    Read the article

  • MATLAB: impoint getPosition strange behaviour

    - by tguclu
    I have a question about the values returned by getPosition. Below is my code. It lets the user set 10 points on a given image: figure ,imshow(im); colorArray=['y','m','c','r','g','b','w','k','y','m','c']; pointArray = cell(1,10); % Construct boundary constraint function fcn = makeConstrainToRectFcn('impoint',get(gca,'XLim'),get(gca,'YLim')); for i = 1:10 p = impoint(gca); % Enforce boundary constraint function using setPositionConstraintFcn setPositionConstraintFcn(p,fcn); setColor(p,colorArray(1,i)); pointArray{i}=p; getPosition(p) end When I start to set points on the image I get results like [675.000 538.000], which means that the x part of the coordinate is 675 and the y part is 538, right? This is what the MATLAB documentation says, but since the image is 576*120 (as displayed in the window) this is not logical. It seemed to me like, somehow, getPosition returns the y coordinate first. I need some clarification on this. Thanks for help

    Read the article

  • How to create closed areas (convex polygons) from set of line segments ?

    - by Marten
    The following problem is in 2D, so some simplifications can be made when suggesting answers. I need to create closed areas (defined either by line segments or just set of points - convex polygon) from a set of points/line segments. Basically I used Voronoi to generate "roads". Then I changed some of the data. Now I need a way to loop through that data (which is still line segments but doesn't comply with Voronoi anymore) and generate "neigbourhoods" that are bordered with the "roads". I looked at some graph diagrams and shortest path theories, but I could not figure it out. Logically it could be done by starting at left edge from one point, finding the way back to that point using the shortest path with available lines (using only clockwise directions). Then mark this line set down and remove from the data. Then you can repeat the same process and get all the areas like that. I tried to implement that but it did not get me anywhere as I could not figure out a way to write a C++ code that could do that. Problem was with choosing the most counterclockwise line from available lines from a specific point. All angle based math I did gave wrong answers because the way sin/cos are implemented in c++. So to summarize - if you can help me with a totally new approach to the problem its good, if not could you help me find a way to write the part of the code that finds the shortest clockwise path back to the beginning point using the line segment set as paths back. Thank you for your help!

    Read the article

  • How to interpolate in MatLab

    - by G Sam
    I have a 1x1 Matrix of points which specifies speed of a drive with respect to time. This speed changes throughout the operation; which means that the difference between two points is changing. To give you an example: M = [1; 2; 3; 5; 7; 9; 11; 15; 19]. (Only that this is a 892x1 matrix) I want to make this matrix twice as long (so changing the relative speed per timestep), while retaining the way the speeds change. Eg: M' = [1; 1.5; 2; 2.5; 3; 4; 5; 6; 7; 8; 9; 10; 11; 13; 15; 17; 19]. Is there an easy way to do this in MatLab? So far I have tried upsampling (which fills the time step with zeros); interp (which fills it with low-pass interpolation. Thanks!

    Read the article

  • Projective transformation

    - by mcwehner
    Given two image buffers (assume it's an array of ints of size width * height, with each element a color value), how can I map an area defined by a quadrilateral from one image buffer into the other (always square) image buffer? I'm led to understand this is called "projective transformation". I'm also looking for a general (not language- or library-specific) way of doing this, such that it could be reasonably applied in any language without relying on "magic function X that does all the work for me". An example: I've written a short program in Java using the Processing library (processing.org) that captures video from a camera. During an initial "calibrating" step, the captured video is output directly into a window. The user then clicks on four points to define an area of the video that will be transformed, then mapped into the square window during subsequent operation of the program. If the user were to click on the four points defining the corners of a door visible at an angle in the camera's output, then this transformation would cause the subsequent video to map the transformed image of the door to the entire area of the window, albeit somewhat distorted.

    Read the article

  • Saving "heavy" image to PDF in MATLAB - rendering problem

    - by yuk
    I generate a figure in MATLAB with lot amount of points (100000+) and want to save it into a PDF file. With zbuffer or painters renderer I've got very large and slowly opened file (over 4 Mb) - all points are in vector format. Using OpenGL renderer rasterize the figure in PDF, ok for the plot, but not good for text labels. The file size is about 150 Kb. Try this simplified code, for example: x=linspace(1,10,100000); y=sin(x)+randn(size(x)); plot(x,y,'.') set(gcf,'Renderer','zbuffer') print -dpdf -r300 testpdf_zb set(gcf,'Renderer','painters') print -dpdf -r300 testpdf_pa set(gcf,'Renderer','opengl') print -dpdf -r300 testpdf_op The actual figure is much more complex with several axes and different types of plots. Is there a way to rasterize the figure, but keep text labels as vectors? Another problem with OpenGL is that is does not work in terminal mode (-nosplash -nodesktop) under Mac OSX. Looks like OpenGL is not supported. I have to use terminal mode for automation. The MATLAB version I run is 2007b. Mac OSX server 10.4.

    Read the article

  • Are there solutions for streamlining the update of legacy code in multiple places?

    - by ccomet
    I'm working in some old code which was originally designed for handling two different kinds of files. I was recently tasked with adding a new kind of file to this code. Most of my problems were solved by filling out an extensive XML file with a new entry that handled everything from what lists were named to how the file is written in plural lower case. But this ended up being insufficient, as there were maybe 50 different places in 24 different code files where I had to update hardcoded switch-statements that only branched for the original two file types. Unfortunately there is no consistency in this; there are methods which operate half from the XML file, and half off of hardcode. Some of the files which look like they would operate off of the XML file don't, and some that I would expect that I'd need to update the hardcode don't need it. So the only way to find the majority of these is to run through testing the whole system when only part of it is operational, finding that one step to fix (when I'm lucky that error logging actually tells me what is going on), and then running the whole thing again. This wastes time testing the parts of the code which are already confirmed to work, time better spent testing the new parts I have to add on top of it all. It's a hassle and a half, and to my luck I can expect that I will have to add yet another new kind of file in the near future. Are there any solutions out there which can aid in this kind of endeavour? Something which I can input some parameters of current features, document what points in a whole code project actually need to be updated, and run something nice the next time I need to add a new feature to the code. It needn't even be fully automated, something that'll help me navigate straight to the specific points in everything and maybe even record what kind of parameters need to be loaded. Doubt it matters specifically, but the code is comprised of ASP.NET pages, some ASP.NET controls, hundreds of C# code files, and a handful of additional XML files. It's all currently in a couple big Visual Studio 2008 projects.

    Read the article

  • CIE XYZ colorspace: do I have RGBA or XYZA?

    - by Tronic
    I plan to write a painting program based on linear combinations of xy plane points (0,1), (1,0) and (0,0). Such system works identically to RGB, except that the primaries are not within the gamut but at the corners of a triangle that encloses the entire gamut. I have seen the three points being referred to as X, Y and Z (upper case) somewhere, but I cannot find the page anymore (I marked them to the picture myself). My pixel format stores the intensity of each of those three components the same way as RGB does, together with alpha value. This allows using pretty much any image manipulation operation designed for RGBA without modifying the code. What is my format called? Is it XYZA, RGBA or something else? Google doesn't seem to know of XYZA. RGBA will get confused with sRGB + alpha (which I also need to use in the same program). Notice that the primaries X, Y and Z and their intensities have little to do with the x, y and z coordinates (lower case) that are more commonly used.

    Read the article

  • Positioning decorated series of div tags on screen using offset, DOM JQUERY RELATED

    - by Calibre2010
    Hi, I am using JQuery to position a series of div tags which basically use a class inside of the tag which decorates the divs as bars. So the div is a green box based on its css specifications to the glass. I have a list of STARTING postions, a list of left coordiantes- for the starting points I wish to position my DIV say 556, 560, 600 these automatically are generated as left positions in a list I have a list of ENDING postions, a list of left coordiantes- for the ending points I wish to position my DIV say 570, 590, 610 these automatically are generated as left positions in a list now for each start and end position, the bar(green box) i want to be drawn with its appropriate width as follows. so say f is the offset or position of the start and ff the offset or position of the end : Below draws the green box based on only one start and end position LEFT. if (f.left != 0) { $("#test").html($("<div>d</div>")).css({ position: 'absolute', left: (f.left) + "px", top: (f.top + 35) + "px", width: (ff.left - f.left) + 25 + "px" }).addClass("option1"); } I am looking to loop through the list of positons in the list and draw multiple green boxs based on the positions on the screen. The above code draws just one green box from the last offset position.

    Read the article

  • Utility of List<T>.Sort() versus List<T>.OrderBy() for a member of a custom container class

    - by ccomet
    I've found myself running back through some old 3.5 framework legacy code, and found some points where there are a whole bunch of lists and dictionaries that must be updated in a synchronized fashion. I've determined that I can make this process infinitely easier to both utilize and understand by converging these into custom container classes of new custom classes. There are some points, however, where I came to concerns with organizing the contents of these new container classes by a specific inner property. For example, sorting by the ID number property of one class. As the container classes are primarily based around a generic List object, my first instinct was to write the inner classes with IComparable, and write the CompareTo method that compares the properties. This way, I can just call items.Sort() when I want to invoke the sorting. However, I've been thinking instead about using items = items.OrderBy(Func) instead. This way it is more flexible if I need to sort by any other property. Readability is better as well, since the property used for sorting will be listed in-line with the sort call rather than having to look up the IComparable code. The overall implementation feels cleaner as a result. I don't care for premature or micro optimization, but I like consistency. I find it best to stick with one kind of implementation for as many cases as it is appropriate, and use different implementations where it is necessary. Is it worth it to convert my code to use the LINQ OrderBy instead of using List.Sort? Is it a better practice to stick with the IComparable implementation for these custom containers? Are there any significant mechanical advantages offered by either path that I should be weighing the decision on? Or is their end-functionality equivalent to the point that it just becomes coder's preference?

    Read the article

  • Webserver sending corrupt or corrupting served files

    - by NotIan
    EDIT: Looks like the problem was a rootkit that corrupted a bunch of low level linux commands, including top, ps, ifconfig, netstat and others. The problem was resolved by taking all web files off the server and wiping it. A dedicated server we operate is having a strange issue. Files are not be sent complete or are showing up with garbage data. Example: http://sustainablefitness.com/images/banner_bootcamps.jpg To make matters more confusing this corruption does NOT happen when the files are served as https, (I would post a link, but I don't have enough rep points, just add an 's' after http in the link above.) When I throw load at the server, I get dozens of (swapd)s in top this is the only thing that really jumps out. I can't post images but ( imgur.com / ZArSq.png ) is a screenshot of top. I have tried a lot of stuff so far, I am willing to try anything that I can. A dedicated server we operate is having a strange issue. Files are not be sent complete or are showing up with garbage data. Example: http://sustainablefitness.com/images/banner_bootcamps.jpg To make matters more confusing this corruption does NOT happen when the files are served as https, (I would post a link, but I don't have enough rep points, just add an 's' after http in the link above.) When I throw load at the server, I get dozens of (swapd)s in top this is the only thing that really jumps out. I can't post images but ( imgur.com / ZArSq.png ) is a screenshot of top. I have tried a lot of stuff so far, I am willing to try anything that I can.

    Read the article

  • WYSIWYG with Qt - font size woes

    - by Rob
    I am creating a custom Qt widget that mimics an A4 printed page and am having problems getting fonts to render at the correct size. My widget uses QPainter::setViewport and QPainter::setWindow to mimic the A4 page, using units of 10ths of a millimetre which enables me to draw easily. However, attempting to create a font at a specific point size doesn't seem to work and using QFont:setPixelSize isn't accurate. Here is some code: View::View(QWidget *parent) : QWidget(parent), printer(new QPrinter) { printer->setPaperSize(QPrinter::A4); printer->setFullPage(true); } void View::paintEvent(QPaintEvent*) { QPainter painter(this); painter.setWindow(0, 0, 2100, 2970); painter.setViewport(0, 0, printer->width(), printer->height()); // Draw a rect at x = 1cm, y = 1cm, 6cm wide and 1 inch high painter.drawRect(100, 100, 600, 254); // Create a 72pt (1 inch) high font QFont font("Arial"); font.setPixelSize(254); painter.setFont(font); // Draw in the same box // The font is too large painter.drawText(QRect(100, 100, 600, 254), tr("Wg\u0102")); // Ack - the actual font size reported by the metrics is 283 pixels! const QFontMetrics fontMetrics = painter.fontMetrics(); qDebug() << "Font height = " << fontMetrics.height(); } So I'm asking for a 254 high font (1 inch, 72 pts) and it's too big and sure enough when I query for the font height via QFontMetrics it is 283 high. Does anyone else know how to use font sizes in points when using custom mapping modes like this? It must be possible. Note that I cannot see how to convert between logical/device points either (i.e. the Win32 DPtoLP/LPtoDP equivalents.)

    Read the article

  • Where should I store shared resources between LocalSystem and regular user with UAC?

    - by rwired
    My application consists of two parts: A Windows Service running under the LocalSystem account and a client process running under the currently logged in regular user. I need to deploy the application across Windows versions from XP up to Win7. The client will retrieve files from the web and collect user data from the user. The service will construct files and data of it's own which the client needs to read. I'm trying to figure out the best place (registry or filesystem, or mix) to store all this. One file the client or service needs to be able to retrieve from the net is an update_patch executable which needs to run whenever an upgrade is available. I need to be sure the initial installer SETUP.EXE, and also the update_patch can figure out this ideal location and set a RegKey to be read later by both client and server telling them the magic location (The SETUP.EXE will run with elevated privileges since it needs to install the service) On my Win7 test system the service %APPDATA% points to: C:\Windows\system32\config\systemprofile\AppData\Roaming and the %APPDATA% of the client points to: C:\Users\(username)\AppData\Roaming Interestingly Google Chrome stores everything (App and Data) in C:\Users\(username)\AppData\Local\Google\Chrome Chrome runs pretty much in exactly the way I want my suite to run (able to silently update itself in the background) What I'm trying to avoid is nasty popups warning the user that the app wants to modify the system, and I want to avoid problems when VirtualStore doesn't exist because the user is running XP/2000/2003 or has UAC turned off. My target audience are non-tech-savvy general Windows users.

    Read the article

  • how to use iterator in c++?

    - by tsubasa
    I'm trying to calculate distance between 2 points. The 2 points I stored in a vector in c++: (0,0) and (1,1). I'm supposed to get results as 0 1.4 1.4 0 but the actual result that I got is 0 1 -1 0 I think there's something wrong with the way I use iterator in vector. Could somebody help? I posted the code below. typedef struct point { float x; float y; } point; float distance(point *p1, point *p2) { return sqrt((p1->x - p2->x)*(p1->x - p2->x) + (p1->y - p2->y)*(p1->y - p2->y)); } int main() { vector <point> po; point p1; p1.x=0; p1.y=0; point p2; p2.x=1; p2.y=1; po.push_back(p1); po.push_back(p2); vector <point>::iterator ii; vector <point>::iterator jj; for (ii=po.begin(); ii!=po.end(); ii++) { for (jj=po.begin(); jj!=po.end(); jj++) { cout<<distance(ii,jj)<<" "; } } return 0; }

    Read the article

  • Collision of dot and line in 2D space

    - by Anderiel
    So i'm trying to make my first game on android. The thing is i have a small moving ball and i want it to bounce from a line that i drew. For that i need to find if the x,y of the ball are also coordinates of one dot from the line. I tried to implement these equations about lines x=a1 + t*u1 y=a2 + t*u2 = (x-a1)/u1=(y-a2)/u2 (t=t which has to be if the point is on the line) where x and y are the coordinates im testing, dot[a1,a2] is a dot that is on the line and u(u1,u2) is the vector of the line. heres the code: public boolean Collided() { float u1 =Math.abs(Math.round(begin_X)-Math.round(end_X)); float u2 =Math.abs(Math.round(begin_Y)-Math.round(end_Y)); float t_x =Math.round((elect_X - begin_X)/u1); float t_y =Math.round((elect_Y - begin_Y)/u2); if(t_x==t_y) { return true; } else { return false; } } points [begin_X,end_X] and [begin_Y,end_Y] are the two points from the line and [elect_X,elect_Y] are the coordinates of the ball theoreticaly it should work, but in the reality the ball most of the time just goes straigth through the line or bounces somewhere else where it shouldnt

    Read the article

  • Matlab matrix translation and rotation multiple times

    - by pinnacler
    I have a map of individual trees from a forest stored as x,y points in a matrix. I call it fixedPositions. It's cartesian and (0,0) is the origin. I would like 0/360 degrees to be the top of the screen and 90 degrees to be to the right. Given a velocity and a heading, i.e. .5 m/s and 60 degrees (2 o'clock equivalent on a watch), how do I rotate that x,y points, so that the new origin is centered at (.5cos(60),.5sin(60)) and 60 degrees is now at the top of the screen? Then if I were to give you another heading and speed, i.e. 0 degrees and 2m/s, it should calculate it from the last point, not the original fixedPositions origin. I've wasted my day trying to figure this out. I wish I took matrix algebra but I'm at a loss. I tried doing cos(30) and even those wouldn't compute correctly, which after an hour I realize were in radians.

    Read the article

  • SQL query recursion for a web-like structure

    - by MickeyD
    I have a table here, named "Foo". The data is set up something like this. ID TableReference DataId0 DataId1 DataId2 -- -------------- ------- ------- ------- 1 Prize 3 4 5 2 Prize 4 5 NULL 3 Cash 1 NULL NULL 4 Prize 8 NULL 12 5 Foo 2 3 NULL 6 Cash 8 1 10 7 Foo 5 1 2 Etc. The data is horribly set up, I know, but I didn't set it up that way. :) I'm only dealing with the after effect. I'm trying to come up with a way to essentially "flatten" the table; that is, to display all the data to a point where the table "Foo" does not reference itself. I'm trying to figure out a sql query that I can do to get there. Usually when I deal with recursion, I have (or can establish) parent IDs and set it up that way, but for this table there are seemingly multiple child and parent IDs creating a web-like structure instead of a hierarchy. So I'm at a loss where to even begin to write a sql query for something like this. Note: There is no infinite looping (where one Foo points to another Foo, which points back to the original Foo) from what I've found. Using t-sql. Thanks for any assistance, if at all possible.

    Read the article

  • NSFetchedResultsController on secondary UITableView - how to query data?

    - by Jason
    I am creating a core-data based Navigation iPhone app with multiple screens. Let's say it is a flash-card application. The data model is very simple, with only two entities: Language, and CardSet. There is a one-to-many relationship between the Language entity and the CardSet entities, so each Language may contain multiple CardSets. In other words, Language has a one-to-many relationship Language.cardSets which points to the list of CardSets, and CardSet has a relationship CardSet.language which points to the Language. There are two screens: (1) An initial TableView screen, which displays the list of languages; and (2) a secondary TableView screen, which displays the list of CardSets in the Language. In the initial screen, which lists the languages, I am using NSFetchedResultsController to keep the list of languages up-to-date. The screen passes the Language selected to the secondary screen. On the secondary screen, I am trying to figure out whether I should again use an NSFetchedResultsController to maintain the list of CardSets, or if I should work through Language.cardSets to simply pull the list out of the object model. The latter makes the most sense programatically because I already have the Language - but then it would not automatically be updated on changes. I have looked at the NSFetchedResultsController documentation, and it seems like I can easily create predicates based on attributes - but not relationships. I.e., I can create the following NSFetchedResultsController: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name LIKE[c] 'Chuck Norris'"]; How can I access my data through the direct relationship - Language.cardSets - and also have the table auto-update using NSFetchedResultsController? Is this possible?

    Read the article

  • Help with mysql sum and group query and managing results for jquery graph.

    - by Scarface
    I have a system I am trying to design that will retrieve information from a database, so that it can be plotted in a jquery graph. I need to retrieve the information and somehow put it in the necessary coordinates format (for example two coordinates var d = [[1269417600000, 10],[1269504000000, 15]];). My table that I am selecting from is a table that stores user votes with fields: points_id (1=vote up, 2=vote down), user_id, timestamp, topic_id What I need to do is select all the votes and somehow group them into respective days and then sum the difference between 1 votes and 2 votes for each day. I then need to somehow display the data in the appropriate plotting format shown earlier. For example April 1, 4 votes. The data needs to be separated by commas, except the last plot entry, so I am not sure how to approach that. I showed an example below of the kind of thing I need but it is not correct, echo "var d=["; $query=mysql_query( "SELECT *, SUM(IF(points_id = \"1\", 1,0))-SUM(IF([points_id = \"2\", 1,0)) AS 'total' FROM points LEFT JOIN topic ON topic.topic_id=points.topic_id WHERE topic.creator='$user' GROUP by timestamp HAVING certain time interval" ); while ($row=mysql_fetch_assoc($query)){ $timestamp=$row['timestamp']; $votes=$row['total']; echo "[$timestamp,$vote],"; } echo "];";

    Read the article

  • How can I split a LINESTRING into two LINESTRINGs at a given point?

    - by sabbour
    Hello, I'm trying to write a function that will split a LINESTRING into two LINESTRINGs given the split point. What I'm trying to achieve is a function that given a LINESTRING and a distance, it will return N LINESTRINGS for the original linestring splitted at multiples of that distance. This is what I have so far (I'm using SQL Server Spatial Tools from CodePlex): DECLARE @testLine geography; DECLARE @slicePoint geography; SET @testLine = geography::STGeomFromText('LINESTRING (34.5157942 28.5039665, 34.5157079 28.504725, 34.5156881 28.5049565, 34.5156773 28.505082, 34.5155642 28.5054437, 34.5155498 28.5054899, 34.5154937 28.5058826, 34.5154643 28.5060218, 34.5153968 28.5063415, 34.5153322 28.5065338, 34.5152031 28.5069178, 34.5150603 28.5072288, 34.5148716 28.5075501, 34.5146106 28.5079974, 34.5143617 28.5083813, 34.5141373 28.5086414, 34.5139954 28.5088441, 34.5138874 28.5089983, 34.5138311 28.5091054, 34.5136783 28.5093961, 34.5134336 28.5097531, 34.51325 28.5100794, 34.5130256 28.5105078, 34.5128754 28.5107957, 34.5126258 28.5113222, 34.5123984 28.5117673)', 4326) DECLARE @pointOne geography; declare @result table (segment geography) DECLARE @sliceDistance float DECLARE @nextSliceAt float SET @sliceDistance = 100 -- slice every 100 meters SET @nextSliceAt = @sliceDistance SELECT @pointOne = @testLine.STStartPoint() WHILE(@nextSliceAt < @testLine.STLength()) BEGIN SELECT @slicePoint = dbo.LocateAlongGeog(@testLine,@nextSliceAt) DECLARE @subLineString geography; SET @subLineString = geography::STGeomFromText('LINESTRING (' + dbo.FloatToVarchar(@pointOne.Long) + ' ' + dbo.FloatToVarchar(@pointOne.Lat) + ',' + dbo.FloatToVarchar(@slicePoint.Long) + ' ' + dbo.FloatToVarchar(@slicePoint.Lat) +')', 4326) insert into @result SELECT @subLineString SET @pointOne = @slicePoint set @nextSliceAt = @nextSliceAt + @sliceDistance END SET @subLineString = geography::STGeomFromText('LINESTRING (' + dbo.FloatToVarchar(@pointOne.Long) + ' ' + dbo.FloatToVarchar(@pointOne.Lat) + ',' + dbo.FloatToVarchar(@testLine.STEndPoint().Long) + ' ' + dbo.FloatToVarchar(@testLine.STEndPoint().Lat) +')', 4326) insert into @result SELECT @subLineString select * from @result I know it is not the best looking code, but there is another problem. The above code approximates the resulting LINESTRING because it does not follow the curvature of the original LINESTRING as it only takes into consideration the start and end points when creating the new segment. Is there a way take a substring out of the original LINESTRING given the start and end points?

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >